GYM 100741A Queries】的更多相关文章

time limit per test 0.25 seconds memory limit per test 64 megabytes input standard input output standard output Mathematicians are interesting (sometimes, I would say, even crazy) people. For example, my friend, a mathematician, thinks that it is ver…
A. Queries time limit per test 0.25 seconds memory limit per test 64 megabytes input standard input output standard output Mathematicians are interesting (sometimes, I would say, even crazy) people. For example, my friend, a mathematician, thinks tha…
传送门 题目大意: 一个长度为n的序列,q次三种操作 +p  r:下标为p的数+r -p r:下标为p的数-r s l r mod [L,R]中有多少数%m=mod,m已经给出 题解: 开十个树状数组 代码 我的 #include<iostream> #include<cstdio> using namespace std; ]; struct Tree{ ]; }s[]; int lowbit(int x){ return x&(-x); } void add(int k…
题目传送门 题目大意: 给定一颗根节点为1的树,有两种操作,第一种操作是将与根节点距离为L的节点权值全部加上val,第二个操作是查询以x为根节点的子树的权重. 思路: 思考后发现,以dfs序建立树状数组,方便查询,不方便修改,以bfs序建立树状数组,方便修改,不方便查询. 在计算子树权重的时候发现,如果我能算出 所有层 属于这棵子树的  点数*对应层需要加上的val,那么就得到了这棵树的总权重.但是显然暴力统计点数会超时,于是我们把用一个分块的想法,对于一层来说,如果这层的总点数小于块的大小,就…
传送门 题目 Mathematicians are interesting (sometimes, I would say, even crazy) people. For example, my friend, a mathematician, thinks that it is very fun to play with a sequence of integer numbers. He writes the sequence in a row. If he wants he increas…
ID Origin Title   4 / 12 Problem A Gym 100589A Queries on the Tree 14 / 41 Problem B Gym 100589B Count Palindromes 18 / 19 Problem C Gym 100589C Find P'th Number   0 / 4 Problem D Gym 100589D Desolation of Smaug   0 / 4 Problem E Gym 100589E Count Di…
BUPT2017 wintertraining(15) #4B Gym - 101138D 题意 a数组大小为n.(1 ≤ n ≤ 50 000) (1 ≤ q ≤ 50 000)(1 ≤ ai ≤ n) q个查询,询问两个区间相同的数有多少对. 题解 [sl,sr]和[tl,tr]区间相同的数的对数可以用\(f[sl,tr]-f[sl,tl]-f[sr,tr]+f[sr,tr]\)计算.\(f[l,r]\)为区间[l,r]内相同的数的对数. 对于每个询问,记录需要计算的f的区间,然后按l/sq…
A. Queries time limit per test:0.25 s memory limit per test:64 MB input:standard input output:standard output Mathematicians are interesting (sometimes, I would say, even crazy) people. For example, my friend, a mathematician, thinks that it is very…
Description 给你一下长度为 \(n\) 的序列. \(a_i=a_j\) \(l_1 \leqslant i \leqslant r_1\) \(l_2 \leqslant i \leqslant r_2\) 询问满足条件的 \((i,j)\) 对数. Sol 分块+前缀和. 非常乱搞啊... 首先分块 \(O(\sqrt{n})\) 一块. 然后在每块里统计块中元素出现次数. 先预处理块与块之间的贡献,然后处理不足一块的. 处理块与块之间的时候,需要前缀和优化一下就可以了,枚举当前…
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an array A of integers of size N, and Q queries. For each query, you will be given a set of distinct integers S and two integers L and R that represent a…