zl程序教程

POJ 3321 Apple Tree

  • POJ 3321 Apple Tree DFS序+fenwick

    POJ 3321 Apple Tree DFS序+fenwick

    题目大意:有一颗长满苹果的苹果树,有两个操作。 1.询问以一个点为根的子树中有多少个苹果。 2.看看一个点有没有苹果,假设没有苹果。那么那里就立即长出一个苹果(= =!);否则就把那个苹果摘下来。 思路:进行一次深搜,将每一个节点最開始出现的时间和最后出现的时间记在一个数组里,那么这两点之间的点就是它以及它的子树的二倍,然后就用树状数组来维护区间和即可了。 CODE: #inclu

    日期 2023-06-12 10:48:40     
  • POJ3321:Apple Tree(树状数组)

    POJ3321: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.

    日期 2023-06-12 10:48:40     
  • 刷题记录:POJ - 2486Apple Tree

    刷题记录:POJ - 2486Apple Tree

    传送门:Vjudge 题目描述: Wshxzt is a lovely girl. She likes apple very much. One day HX takes her to an apple tree. Th

    日期 2023-06-12 10:48:40     
  • POJ 2486 Apple Tree

    POJ 2486 Apple Tree

                                     

    日期 2023-06-12 10:48:40     
  • POJ 2486 Apple Tree

    POJ 2486 Apple Tree

    Apple Tree Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 248664-bit integer IO format: %lld      Java class name:&

    日期 2023-06-12 10:48:40     
  • poj 3321 Apple Tree(分块大法)

    poj 3321 Apple Tree(分块大法)

    题目大意: 给你一颗树,最初每个节点上都有一个苹果,有两种操作: 1,修改(即修改某一个节点,修改时这一个节点苹果从有到无,或从无到有。 2,查询(查询某一个节点他的子树上有多少个苹果)。 解决这

    日期 2023-06-12 10:48:40     
  • 【POJ 3321】Apple Tree

    【POJ 3321】Apple Tree

    有n个节点以1为根节点的树,给你树的边关系u-v,一开始每个节点都有一个苹果,接下来有两种操作,C x改变节点x的苹果状态,Q x查询x为根的树的所有苹果个数。   求出树的dfs序,st[i]保存i的进入时间戳,ed[i]保存i的退出时间戳,则st[i]到ed[i]就是子树节点的对应时间戳。 每个节点打了两次时间戳,其中ed[i]会等于最后访问的一个子节点的st[i]。 于是用线段树

    日期 2023-06-12 10:48:40     
  • POJ - 3321 Apple Tree (线段树 + 建树 + 思维转换)

    POJ - 3321 Apple Tree (线段树 + 建树 + 思维转换)

    POJ - 3321 Apple Tree Time Limit: 2000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status Description There is an apple tree

    日期 2023-06-12 10:48:40     
  • poj2486--Apple Tree(树状dp)

    poj2486--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.

    日期 2023-06-12 10:48:40