poj 3321 Apple Tree(dfs标号+树状数组)

MacOS Intel芯片实战:Docker Compose一键部署Dify全流程解析 本文详细解析了在搭载Intel芯片的MacOS系统上,使用Docker Compose一键部署开源LLM应用开发平台Dify的全流程。内容涵盖环境准备、Docker配置与镜像加速、代码拉取与配置初始化、服务启动与问题排查,以及访问验证与初步探索,旨在帮助开发者快速在本地搭建私有化AI应用开发环境。 阅读详情
题意:
给出一个苹果树,每个节点一开始都有苹果
C X,如果X点有苹果,则拿掉,如果没有,则新长出一个
Q X,查询X点与它的所有后代分支一共有几个苹果

很好的一个题,讲一个树通过标号,巧妙的转换成了树状数组。


参考思路:点击打开链接

思路很巧妙,我们通过自己来编号所有苹果,每个节点保存两个值,左值为本身,右值为

其包含的所有后代中最大的编号

我们可以通过搜索来进行编号,在编好号之后,我们可以知道,对于某一点而言,我们是

先通过这个点搜完所有他的后代编号才结束的,所以这个点的右值,包含了当前点所有的

后代与祖先,后代必然是所有编号大于本节点的点,那么祖先呢,那必然是编号小于这个

节点的点了。

所以我们通过sum(rig[x])-sum(lef[x]-1)就能得到查询的答案

至于更新,只需要更新当前点即可,这样就转化为树状数组了。



代码:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 1e5+5;
int n, m, k, num, cur, head[maxn], l[maxn], r[maxn], tree[maxn];
struct node
{
    int v, next;
}edge[maxn];

void addEdge(int u, int v)
{
    edge[k].v = v;
    edge[k].next = head[u];
    head[u] = k++;
}

void dfs(int cur)
{
    l[cur] = num;
    for(int i = head[cur]; i != -1; i = edge[i].next)
    {
        num++;;
        dfs(edge[i].v);
    }
    r[cur] = num;
}

int lowbit(int x) { return x&(-x); }

void update(int pos, int val)
{
    while(pos < maxn)
    {
        tree[pos] += val;
        pos += lowbit(pos);
    }
}

int query(int pos)
{
    int sum = 0;
    while(pos)
    {
        sum += tree[pos];
        pos -= lowbit(pos);
    }
    return sum;
}

int main(void)
{
    while(cin >> n)
    {
        k = 0;
        memset(tree, 0, sizeof(tree));
        memset(head, -1, sizeof(head));
        for(int i = 1; i < n; i++)
        {
            int u, v;
            scanf("%d%d", &u, &v);
            addEdge(u, v);
        }
        for(int i = 1; i <= n; i++) update(i, 1);
        num = 1;
        dfs(1);
        scanf("%d", &m);
        while(m--)
        {
            char cmd;
            int x;
            scanf(" %c%d", &cmd, &x);
            if(cmd == 'C')
            {
                if(query(l[x])-query(l[x]-1)) update(l[x], -1);
                else update(l[x], 1);
            }
            else printf("%d\n", query(r[x])-query(l[x]-1));
        }
    }
    return 0;
}



Apple Tree
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 27221 Accepted: 8078

Description

There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.

The tree has N forks which are connected by branches. Kaka numbers the forks by 1 to N and the root is always numbered by 1. Apples will grow on the forks and two apple won't grow on the same fork. kaka wants to know how many apples are there in a sub-tree, for his study of the produce ability of the apple tree.

The trouble is that a new apple may grow on an empty fork some time and kaka may pick an apple from the tree for his dessert. Can you help kaka?

Input

The first line contains an integer N (N ≤ 100,000) , which is the number of the forks in the tree.
The following N - 1 lines each contain two integers u and v, which means fork u and fork v are connected by a branch.
The next line contains an integer M (M ≤ 100,000).
The following M lines each contain a message which is either
"C x" which means the existence of the apple on fork x has been changed. i.e. if there is an apple on the fork, then Kaka pick it; otherwise a new apple has grown on the empty fork.
or
"Q x" which means an inquiry for the number of apples in the sub-tree above the fork x, including the apple (if exists) on the fork x
Note the tree is full of apples at the beginning

Output

For every inquiry, output the correspond answer per line.

Sample Input

3
1 2
1 3
3
Q 1
C 2
Q 1

Sample Output

3
2

Source

POJ Monthly--2007.08.05, Huang, Jinsong


educoder 5-3Python 计算思维训练——地图模拟 任务描述 本关任务:利用 Python 实现动画观察近 30 天 4.5 级以上地震发生情况。 相关知识 为了完成本关任务,你需要掌握:1.如何用 Python 从网络获取所需数据;2.如何用 Python 绘制地图 从网络获取数据 URL 处理模块(库) 在这里插入代码片 import urllib.request as req 创建一个表示远程 url 的类文件对象 urllib.urlopen(" ") 如同本地文件一样读取内容 print data的输出结果: 摘取动画所需数据 阅读详情

相关推荐

Aurora8b10b光口通信实战:复位时序与IP核配置详解

本文深入解析了Aurora 8B10B协议在FPGA高速光口通信中的核心实践,重点剖析了确保链路稳定启动的关键复位时序与IP核配置细节。通过详解全双工与单工模式下的复位流程、Vivado中IP核的物理层与链路层参数设置,并结合用户逻辑设计实例,为工程师实现可靠的高速数据传输提供了清晰的实战指南。

weixin_29280219的博客 186

POJ 3321 Apple Tree【树状数组】

题目 There is an apple tree outside of kaka’s house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree. The tree has N forks which are connected by branches. Kaka numbers t

QYQHxyh的博客 1214

项目管理中 PMO 的关键职能解析

在企业数字化转型与战略落地的浪潮中,PMO(Project Management Office,项目管理办公室)逐渐从“项目辅助角色”升级为“组织级战略执行中枢”。然而,多数人对PMO的认知仍停留在“管项目的部门”或“文档审核机器”的层面。本文将打破误解,通过生活化类比(如“中枢神经”“导航系统”)、流程图解(战略对齐循环)、实际案例(制造企业PMO升级),深入解析PMO的五大核心职能:战略对齐、流程标准化、资源管理、绩效监控、知识沉淀。最终揭示PMO的本质——

项目管理的博客 1258

poj3321---Apple Tree

题目大意: 给你一颗苹果树,树的主干设为1,每一个分支设为一个数,一直到N,代表这颗苹果树。每个分支上面只能最多有一个苹果,也就是一个枝子上面不可能有两个苹果,另外注意一点,不要把苹果树想象成二叉树,苹果树每个节点可以分出很多叉,应该是多叉树。   输入是叉之间的关系, 1 2 1 3 就是主干上面两个叉分别是2 和3.   下面是两种操作,Q 和C C   j  的意思是如果

zhang20072844的专栏 5744

指导初学者使用Anaconda运行GitHub上One - DM项目的步骤

指导初学者使用Anaconda运行GitHub上One - DM项目的步骤。

AI的内部世界的博客 1490

RT-Thread与ROS2通信:micro-ROS在STM32上的移植实践

本文详细介绍了在STM32平台上使用RT-Thread实时操作系统移植micro-ROS实现与ROS2通信的实践方案。通过对比rosserial方案,重点阐述了micro-ROS基于XRCE-DDS协议栈在数据可靠性(丢包率低于1%)、双模式通信(UDP/串口)以及C/C++混合编程方面的优势,为嵌入式设备与ROS2的高效通信提供了完整解决方案。

emacs5lisp的博客 339

POJ 2486:Apple Tree(树形DP)

Apple Tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7789 Accepted: 2606 Description Wshxzt is a lovely girl. She likes apple very much. One day HX takes her to an apple tree. The...

weixin_44003265的博客 312

保姆级教程:从Salmon输出到DESeq2,搞定RNA-seq表达矩阵标准化与下游分析准备

本文提供从Salmon输出到DESeq2标准化的RNA-seq数据分析全流程指南,详细解析表达矩阵构建、标准化方法选择及下游分析准备。重点介绍如何将Salmon定量结果转换为DESeq2兼容格式,包括TPM与原始计数的处理技巧,以及常见问题排查方法,帮助研究人员高效完成RNA-seq数据分析。

weixin_42699679的博客 314

【POJ.3321】Apple Tree(树状数组)

Apple Tree Description There is an apple tree outside of kaka’s house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree. The tree has N forks which are connected by branc

我很菜的好吧 1489

基于FPGA的UDP 通信(六)

本文基于FPGA和MATLAB对千兆以太网通信模块UDP数据发送(FPGA发送)进行联合调试。

记录所学,分享知识,结识挚友 4734

IP-Guard安全网关实例

企业相关情况: 1.OA系统,主要为日常工作使用,该系统IP为192.168.1.2,端口为8080; 2.文件共享服务器,用于存放日常工作资料和文档,该文件共享服务器的IP为192.168.1.1,其中\\192.168.1.1\private 目录中的存放着公司重要文档,不能随意外传; 3.安全网关已采用串联的方式联入网络,IP为192.168.2.6,所有机器访问OA系统和文件共享服务...

IP-Guard专栏 713

Apple Tree 【POJ - 2486】【树形DP】

题目链接 开始学习树形DP的第一题,算是无师自通吧。。。 题目求的是给你一棵数,以及能走的步数,问你走多能吃几颗苹果,如果化成一维的,很容易让人想到运用DP来解这道题,前一刻的步骤会影响后一刻的值,那么如今苹果被挂在了树上,我们就该用树形DP来解了。 树形DP及其推导:  这是道树形DP,题目如是讲到,于是就是处理它了,在这棵树上,我们想拿最多的苹果,首先我们知道从第u个节点向外走,如果一步...

既然弱小,就只顾变强就是了 251

神经形态芯片:IBM TrueNorth技术详解以及应用案例

2018年的一项演示中,机器人使用TrueNorth处理了复杂的路径规划,功耗仅为传统系统的1/10。它通过模仿人脑的结构,解决了传统芯片在功耗和并行性上的痛点,并在图像识别、物联网和机器人等领域展现了强大潜力。:不同于传统芯片的时钟驱动,TrueNorth是事件驱动的。例如,工厂中的振动传感器使用TrueNorth检测设备故障的早期迹象,实现了更高效的维护策略,避免了停机时间。:在医疗领域,TrueNorth可以用于可穿戴设备,比如一个智能助听器,它能过滤噪音并增强特定声音,功耗低到可以用纽扣电池供电。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 2495

【POJ 3321】 Apple Tree (dfs重标号设区间+树状数组求和)

【POJ 3321】 Apple Tree (dfs重标号设区间+树状数组求和) Apple Tree Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 21966   Accepted: 6654 Description There is an app

ACMer' 2575

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

POJ 3321 Apple Tree 题解

POJ 3321题解

DarkoDu的博客 1032

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【树状数组】 ◆POJ 3321◆ Apple Tree

◆POJ 3321◆(2007 POJ Monthly Contest, Aug.) Apple Tree ◆题目◆ Description There is an apple tree outside of kaka’s house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple

Lucky_Glass的C++之旅 690

E - Apple Tree(DFS序,树状数组)

E - Apple Tree POJ - 3321 题意: ​ 一颗苹果树,刚开始所有节点都有苹果,有以下两种操作,一种是改变一个节点的状态(有苹果就取走,没苹果就产生一个),一种是询问一个点的子树(包括节点自己)一共有多少个苹果,对于每次询问输出结果 分析: 重新DFS序给节点标号,那么没个节点的子孙就对应一个连续的区间。那么修改点的状态相当于单点修改,查询操作相当于区间求和,树状数组和线段树...

Dch19990825的博客 364

POJ 3321 Apple Tree (树状数组)

题目链接:http://poj.org/problem?id=3321 题意:有一棵苹果树,最开始长满了苹果。有两种操作,C操作用于修改某个结点,若原来有苹果,则去掉,若原来没苹果,则加上。Q操作询问某个结点及其所有子树总苹果数量。 思路:树状数组的操作,可以从树根开始进行一次DFS,对每个结点进行标号。易知,某个结点及其子树的标号一定是一个连续的区间,这样,记录好每个结点的区间范围,求和时应

Interstellar_的博客 519

poj3321——Apple Tree

题目大意:给出一颗N个节点的苹果树,每个节点只能长一个苹果,根节点标号1。苹果树一开始每个结点都有一个苹果。现在有两种操作,C  x是改变某个节点(如果x节点有苹果就吃掉,如果x结点没有苹果就是长出来一个新苹果);P  x是查询以节点x为根的子树有多少个苹果(包括x节点本身) 输入:N(N ≤ 100,000)            u  v(节点编号,意思是uv两个节点之间有一条边,共N-1

tzyshiwolaogongya的博客 373

POJ 3321 Apple Tree

这两天比赛好多啊。当好不容易可以静下心来写一道题时却发现,树状数组是神马??忘光了诶~~~ 这逗的不是一星半点啊,又看了好长时间。终于可以写这道题了! 题目大意: 给出N个点,N-1条边的无向图,处理成以一号节点为根的树。每个节点上有一个苹果。 有两种操作: 1、操作C:将给定节点的苹果状态修改,若有苹果就变为没有,若没有就变为有。 2、操作Q:输出以...

dhn37379的博客 196

POJ 3321 Apple Tree dfs序 树状数组

题目链接:POJ 3321 Apple Tree Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 30613   Accepted: 9148 Description There is an apple tree outside of kaka's

teddywang 442

POJ 3321 Apple Tree(DFS+树状数组)

转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove  题目:给出一棵树,初始每个结点一个苹果,有修改操作,改变某个结点的状态,有查询操作,某棵子树的苹果数量 http://poj.org/problem?id=3321 首先DFS一次,给每个节点重新标号,并且给每个结点一个区间,表示他的

窝不是爱酱,喵~~~~ 1654

Poj 3321 Apple Tree(树变序列+时间戳+树状数组)

题目链接:http://poj.org/problem?id=3321 题意:一棵具有n个节点的树,一开始,每个节点上都有一个苹果。现在给出m组动态的操作:(C,i)是摘掉第i个节点上面的苹果(若苹果不存在,则为加上一个苹果),(Q,i)是查询以第i个节点为根的子树有几个苹果(包括第i个节点)。 思路:用DFS时间戳的方法将树转变为序列:做一次dfs,记下每个节点的开始时间Start[i]和结

whyorwhnt的专栏 1113

poj 3321 Apple Tree(树状数组)

我一直不知道树状数组和线段树有什么区别,算法不同,但我感觉他们解决的问题差不多。 由于此题数据比较大(N 另外为每一个节点赋一个左值和一个右值,表示这个节点的管辖范围。 这样有了每个节点的左值和右值就可以用树状数组解决了 树状数组详解:http://blog.csdn.net/clx55555/article/details/52261538 #include

但求心安的博客 403

poj 3321 Apple Tree(dfs + 树状数组)

Apple Tree Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16777   Accepted: 5075 Description There is an apple tree outside of kaka's house. Every autumn, a

WEYuLi的专栏 1418

POJ 3321 Apple Tree 【树形结构转变为线性结构+线段树OR树状数组】

Apple Tree Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 21587   Accepted: 6551 POJ 3321 链接: Description There is an apple tree outside of kaka's house.

Fighting! 3485
上一篇: uva 10870 Recurrences(矩阵快速幂)
下一篇: hdoj 2852 KiKi's K-Number(树状数组+二分)
cillyb
博客等级 码龄11年 225粉丝 497原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值