题面 One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when he got results only for season 7 episode 3 with his search query of "Watch Tufurama season 3 episode 7 on…
In the lattice points of the coordinate line there are n radio stations, the i-th of which is described by three integers: xi — the coordinate of the i-th station on the line, ri — the broadcasting range of the i-th station, fi — the broadcasting fre…
In this problem you will meet the simplified model of game Pudding Monsters. An important process in developing any game is creating levels. A game field in Pudding Monsters is an n × n rectangular grid, n of its cells contain monsters and some other…
Codeforces 848C Goodbye Souvenir Problem : 给一个长度为n的序列,有q个询问.一种询问是修改某个位置的数,另一种询问是询问一段区间,对于每一种值出现的最右端点的下标与最左端点的下标的差值求和. Solution : 定义pre[i] 为 第i个位置的数字上一次出现位置,对于询问l, r 就是对于所有满足 l <= pre[i] < i <= r 的点求和,权值为 i - pre[i]. 因此可以把这个看作是三维偏序的问题,第一维时间,第二维,第三…
Educational Codeforces Round 41 (Rated for Div. 2) E. Tufurama (CDQ分治 求 二维点数) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Polycarp decided to rewatch his absolute favourite epi…
题意: 有一个无向连通图,支持三个操作: 1 x y d : 新建一条x和y的无向边,长度为d 2 x y :删除x和y之间的无向边 3 x y :询问x到y的所有路径中(可以绕环)最短的是多少(路径长度是经过所有边的异或) n,m,q<=2e5 分析: 如果没有加边和删边操作,那么就是个经典的线性基问题 我们可以先弄出一个树,然后非树边就形成环,把环丢进线性基就可以了 现在有了加边和删边操作,我们可以考虑每条边的存活时间,对这个时间进行cdq分治,那么就只有加边没有删边了 然后再离…
题目传送门 题意:现在有3种操作, 1 t x 在t秒往multiset里面插入一个x 2 t x 在t秒从multiset里面删除一个x 3 t x 在t秒查询multiset里面有多少x 事情是按照输入顺序发生的,这个人有一个时光机,可以穿梭到那一秒去执行操作. 题解:CDQ分治.3维偏序,第一维是输入顺序,第二维t,然后直接map处理数据就好了. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen(…
Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares form an S * S matrix with the rows and columns numbered from 0 to S-1. Each square contains a base sta…