###### 六一儿童节题解QAQ

T1：

n,m<=30000

#include <algorithm>
#include <cstdio>
#include <cstring>
#define Rep(i,n) for(int i = 1;i <= n;i ++)
#define u t[x]
#define o t[y]
#define mid (l + r >> 1)
#define lson u.lc,l,mid
#define rson u.rc,mid + 1,r
using namespace std;
const int N = 30005;
const int NN = ((1 << 30) - 5);
int tot = 0,n,m,ql,qr,qwl,qwr,K,rt[N];
struct Seg{int lc,rc,cnt;}t[N << 5];
void Ins(int &x,int l,int r,int val,int ct,int y)
{
if(!x)x = ++ tot;
u.cnt = o.cnt;
u.cnt += ct;
if(l == r)return;
if(val <= mid)Ins(lson,val,ct,o.lc),u.rc = o.rc;
else Ins(rson,val,ct,o.rc),u.lc = o.lc;
}
int Qry_val(int x,int l,int r,int y)
{
if(l >= qwl && r <= qwr)
return u.cnt - o.cnt;
int a1 = 0,a2 = 0;
if(qwl <= mid)a1 = Qry_val(lson,o.lc);
if(mid < qwr)a2 = Qry_val(rson,o.rc);
return a1 + a2;
}
int Qry(int x,int l,int r,int y)
{
if(l == r)return l;
int Now = t[u.lc].cnt - t[o.lc].cnt;
if(Now < K)return K -= Now,Qry(rson,o.rc);
else return Qry(lson,o.lc);
}
int main ()
{
freopen("building.in","r",stdin);
freopen("building.out","w",stdout);
scanf("%d",&n);
Rep(i,n)
{
int a,b;
scanf("%d%d",&a,&b);
Ins(rt[i],1,NN,a,b,rt[i - 1]);
}
scanf("%d",&m);
Rep(i,m)
{
scanf("%d%d%d%d%d",&ql,&qr,&qwl,&qwr,&K);
int cpt = Qry_val(rt[qr],1,NN,rt[ql - 1]);
if(cpt < K){puts("-1");continue;}
swap(qwl,qwr),qwl = 1,qwr --;
int cpp;
if(qwl > qwr)cpp = 0;
else cpp = Qry_val(rt[qr],1,NN,rt[ql - 1]);
K = cpp + K;
printf("%d\n",Qry(rt[qr],1,NN,rt[ql - 1]));
}
return 0;
}

T2：

n<=1000,m<=6000

T3：

s[i - > i + k - 1] == s[j - > j + k - 1]
s[i + k] > s[j + k]

#include <cstdio>
#include <cstring>
#define Rep(i,n) for(int i = 1;i <= n;i ++)
using namespace std;
int s[300005],n;
int Get(int *a)
{
int i = 1,j = 2,k = 0,len = n;
while(i <= n && j <= n && k <= n)
{
if(k == n)return i;
if(i == j)j ++;
int ni = i + k,nj = j + k;
if(ni > len)ni -= len;
if(nj > len)nj -= len;
if(a[ni] > a[nj])i += k + 1,k = 0;
else if(a[nj] > a[ni])j += k + 1,k = 0;
else k ++;
}
return i;
}
int main ()
{
freopen("work.in","r",stdin);
freopen("work.out","w",stdout);
scanf("%d",&n);
Rep(i,n)scanf("%d",&s[i]);
int pos = Get(s);
for(int i = pos;i <= n;i ++)
printf("%d ",s[i]);
for(int i = 1;i < pos;i ++)
printf("%d ",s[i]);
puts("");
return 0;
}

T3死因：后缀数组写不出来，水不过。

#### 数位DP.pdf

2015年07月12日 655KB 下载

#### 今天是六一儿童节

2007-06-01 22:18:00

#### 大学生网页制作(六一儿童节)

2012年11月28日 11.94MB 下载

#### 六一儿童节童心AI矢量素材

2018年04月09日 1.22MB 下载

#### 小孩子语录——庆祝六一儿童节

2007-06-01 23:57:00

#### 送分了QAQ

2018-01-28 18:24:22

#### codeforce_894A_字符串水_找出子串所有QAQ可以不连续

2017-12-03 14:01:38

#### 【真题】拼多多2018校招内推编程题 六一儿童节

2017-08-11 16:32:08

#### G-送分了QAQ

2018-01-28 21:23:45

#### 我要六一儿童节礼物！！DecoratorPattern----装饰模式

2017-05-31 20:37:51