1112 - Curious Robin Hood PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 64 MB Robin Hood likes to loot rich people since he helps the poor people with this money. Instead of keeping all the money together he does another trick.…
题目描述 输入 输出 样例输入 样例输出 1 2 题解 二维树状数组 一开始没看到 1≤c≤100 ,想到了主X树和X块,结果发现c的范围那么小... 二维树状数组水题,和一维的一样,向上修改,向下查询,把一个范围变为4个范围处理. #include <cstdio> int a[310][310] , f[110][310][310] , n , m; void update(int p , int x , int y , int a) { int i , j; for(i = x ; i…
这题90%以上的人做法为裸的平衡树,实际上根本没必要还常数大,最好的方法是二分+树状数组.具体做法是,开3倍内存,初始把中间n位赋值为1.对于每个操作:1&2.删除该位,将其丢在头/尾(开三倍内存的原因).3.插入时直接二分查询第ask(x)+y位,换一下即可.4.直接查询.5.二分查询.复杂度O(nlog2n) #include<bits/stdc++.h> using namespace std; ; int n,m,a[N],id[N],c[N]; *m+n)c[x]+=v,x+…
Stars Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/65536 K (Java/Others) Total Submission(s): 785 Accepted Submission(s): 335 Problem Description Yifenfei is a romantic guy and he likes to count the stars in the sky. To make the p…