[CF641E]Little Artem and Time Machine
Little Artem and Time Machine
题解
很水的一道CDQ。
很容易发现这是一道三维偏序:操作顺序,时间轴与x的值。
由于操作顺序这一维是已经排好序的了,我们可以不去动它,再按照第二维进行CDQ。
按照第二维分治时通过操作的状态将左区间的操作影响添加到右区间上。
因为它只在时才会产生影响,我们需要用桶将其记录下来。因为需要用桶,所以在开始的时候还需要进行一次离散化。
源码
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define lowbit(x) (x&-x)
#define MAXN 100010
typedef long long LL;
#define int LL
typedef pair<int,int> pii;
template<typename _T>
void read(_T &x){
_T f=1;x=0;char s=getchar();
while(s>'9'||s<'0'){if(s=='-&#

浙公网安备 33010602011771号