离线dfs CF div2 707 D】的更多相关文章

http://codeforces.com/contest/707/problem/D 先说一下离线和在线:在线的意思就是每一个询问单独处理复杂度O(多少多少),离线是指将所有的可能的询问先一次都处理出来,最后对于每个询问O(1)回答. 然后说一下cf的这题: D. Persistent Bookcase time limit per test 2 seconds memory limit per test 512 megabytes input standard input output st…
https://www.luogu.org/problemnew/show/P3379 1.欧拉序+rmq(st) /* 在这里,对于一个数,选择最左边的 选择任意一个都可以,[left_index,right_index],深度都大于等于这个数的深度 */ #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <time.h> #inc…
题目链接:http://codeforces.com/problemset/problem/707/D  有一个n*m的书架,有K个操作,求每个操作后一共有多少本书:有4种操作: 1:x y 如果 x y 位置没有书,放一本书在上面: 2:x y如果 x y 位置有书,移走: 3:x,表示把第x行的所有又书的拿走,没书的放上去: 4:k,回到第k个操作后的状态: 离线处理k个操作:当操作不为 4 时,把操作i连在i-1后,=4时把操作 i 连在a[i].x后: 这样建一棵树,然后遍历即可,在回溯…
D. Dima and Bacteria time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dima took up the biology of bacteria, as a result of his experiments, he invented k types of bacteria. Overall, there a…
题意,给出边和权值,求出两个点间的最短距离. 用离线算法的时候有个地方不知道怎么处理了.在线的本来想用倍增的,但发现倍增算法貌似需要预处理深度而不是权值,不知道怎么处理.套一个rmq的模板吧,用来处理权值的时候. 代码: #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; const int NN=100010; int…
链接:https://ac.nowcoder.com/acm/contest/392/H 来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 华华看书了解到,一起玩养成类的游戏有助于两人培养感情.所以他决定和月月一起种一棵树.因为华华现在也是信息学高手了,所以他们种的树是信息学意义下的. 华华和月月一起维护了一棵动态有根树,每个点有一个权值.刚开存档的时候,树上只有 0 号节点…
D. Long Path time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at th…
D. Upgrading Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have an array of positive integers a[1], a[2], ..., a[n] and a set of bad prime numbers b1, b2, ..., bm. The prime num…
D. Minesweeper 1D time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Game "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is n squares. S…
D. Toy Sum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a tri…