QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#384921 | #7456. rdCcot | zhouhuanyi | 80 | 1996ms | 210512kb | C++14 | 6.2kb | 2024-04-10 13:49:30 | 2024-04-10 13:49:30 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define N 300000
#define M 600000
#define W 1048576
using namespace std;
const int inf=(int)(1e9);
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
struct reads
{
int x,y;
bool operator < (const reads &t)const
{
return x>t.x;
}
};
reads tong[M+1];
struct rds
{
int num,data,snum;
bool operator < (const rds &t)const
{
return data<t.data;
}
};
rds st[N+1];
int n,m,C,limit,srt,leng,length,wp[N+1],rk[N+1],depth[N+1],smz,sz[N+1],szt[N+1],dis[N+1],maxp[N+1],ans[M+1],sl[N+1],sr[N+1],delta[N+1];
vector<int>E[N+1];
vector<rds>v[N+1];
bool used[N+1],vis[N+1];
bool cmp(int x,int y)
{
return depth[x]<depth[y];
}
void add_edge(int x,int y)
{
E[x].push_back(y),E[y].push_back(x);
return;
}
void dfs(int x)
{
used[x]=1;
for (int i=0;i<E[x].size();++i)
if (!used[E[x][i]])
depth[E[x][i]]=depth[x]+1,dfs(E[x][i]);
return;
}
void get_rt(int x)
{
sz[x]=vis[x]=1,maxp[x]=0;
for (int i=0;i<E[x].size();++i)
if (!used[E[x][i]]&&!vis[E[x][i]])
get_rt(E[x][i]),sz[x]+=sz[E[x][i]],maxp[x]=max(maxp[x],sz[E[x][i]]);
maxp[x]=max(maxp[x],smz-sz[x]),vis[x]=0;
if (maxp[x]<maxp[srt]) srt=x;
return;
}
void dfs2(int x)
{
st[++leng]=(rds){x,dis[x]},vis[x]=szt[x]=1;
for (int i=0;i<E[x].size();++i)
if (!used[E[x][i]]&&!vis[E[x][i]])
dis[E[x][i]]=dis[x]+1,dfs2(E[x][i]),szt[x]+=szt[E[x][i]];
vis[x]=0;
return;
}
struct seg
{
int wl[W+1],wr[W+1],num[W+1],snum[W+1],minn[W+1];
void build(int k,int l,int r)
{
wl[k]=l,wr[k]=r,snum[k]=0,minn[k]=inf;
if (l==r)
{
num[l]=k,snum[k]=l;
return;
}
int mid=(l+r)>>1;
build(k<<1,l,mid),build(k<<1|1,mid+1,r);
return;
}
void push_up(int k)
{
minn[k]=min(minn[k<<1],minn[k<<1|1]);
return;
}
void change(int x,int d)
{
x=num[x],minn[x]=d;
while (x!=1) x>>=1,push_up(x);
return;
}
int find(int x,int d,int d2)
{
if (minn[1]>=d) return -1;
int k=-1;
x=num[x];
while (x!=1)
{
if (x&1)
{
if (minn[x^1]<d)
{
k=x^1;
break;
}
}
x>>=1;
}
if (k==-1) return -1;
while (!snum[k])
{
if (minn[k<<1|1]<d) k=k<<1|1;
else k<<=1;
}
return snum[k];
}
int find2(int x,int d,int d2)
{
if (minn[1]>=d) return -1;
int k=-1;
x=num[x];
while (x!=1)
{
if (!(x&1))
{
if (minn[x^1]<d)
{
k=x^1;
break;
}
}
x>>=1;
}
if (k==-1) return -1;
while (!snum[k])
{
if (minn[k<<1]<d) k<<=1;
else k=k<<1|1;
}
return snum[k];
}
};
seg T;
bool cmp2(rds x,rds y)
{
return x.num<y.num;
}
void solve(int x)
{
int d,ps=0;
leng=0,used[x]=1,dis[x]=0,dfs2(x),sort(st+1,st+leng+1,cmp2);
for (int i=1;i<=leng;++i) st[i].snum=i,delta[i]=st[i].num;
sort(st+1,st+leng+1),limit=1;
while (limit<leng) limit<<=1;
T.build(1,1,limit);
for (int i=leng;i>=1;--i)
{
while (ps+1<=leng&&st[ps+1].data+st[i].data<=C) ++ps,T.change(st[ps].snum,rk[st[ps].num]);
if (ps)
{
d=T.find(st[i].snum,rk[st[i].num],sl[st[i].num]);
if (d!=-1) sl[st[i].num]=max(sl[st[i].num],delta[d]);
d=T.find2(st[i].snum,rk[st[i].num],sr[st[i].num]);
if (d!=-1) sr[st[i].num]=min(sr[st[i].num],delta[d]);
}
}
for (int i=0;i<E[x].size();++i)
if (!used[E[x][i]])
srt=0,smz=szt[E[x][i]],get_rt(E[x][i]),solve(srt);
return;
}
struct dst
{
int x,y,d,d2;
};
dst dque[M+1];
int top,rt[N+1],srk[N+1],c[N+1];
int lowbit(int x)
{
return x&(-x);
}
void add(int x,int d)
{
x=n-x+1;
for (;x<=n;x+=lowbit(x)) c[x]+=d;
return;
}
int query(int x)
{
x=n-x+1;
int res=0;
for (;x>=1;x-=lowbit(x)) res+=c[x];
return res;
}
int find(int x)
{
if (rt[x]==x) return x;
return find(rt[x]);
}
void unionn(int x,int y,int op)
{
int sx=op?x:0;
x=find(x),y=find(y);
if (srk[x]>srk[y]) swap(x,y);
dque[++top]=(dst){x,y,srk[y],sx},rt[x]=y,srk[y]=max(srk[y],srk[x]+1);
if (sx) add(sx,1);
return;
}
void undo()
{
rt[dque[top].x]=dque[top].x,srk[dque[top].y]=dque[top].d;
if (dque[top].d2) add(dque[top].d2,-1);
top--;
return;
}
void calc(int l,int r,vector<reads>p)
{
if (l==r)
{
int cnt=0;
for (int i=0;i<p.size();++i)
if (find(p[i].x)!=find(p[i].y))
cnt++,unionn(p[i].x,p[i].y,1);
for (int i=0;i<v[l].size();++i) ans[v[l][i].num]=l-v[l][i].data+1-query(v[l][i].data);
for (int i=1;i<=cnt;++i) undo();
return;
}
vector<reads>sp;
vector<reads>A;
vector<reads>B;
int mid=(l+r)>>1,cnt=0;
for (int i=0;i<p.size();++i)
{
if (p[i].y<=l)
{
if (find(p[i].x)!=find(p[i].y)) cnt++,unionn(p[i].x,p[i].y,0),sp.push_back(p[i]);
}
else
{
if (find(p[i].x)!=find(p[i].y)) sp.push_back(p[i]);
}
}
for (int i=1;i<=cnt;++i) undo();
p=sp,sp.clear(),sp.shrink_to_fit(),cnt=0;
for (int i=0;i<p.size();++i)
{
if (p[i].y<=l)
{
if (find(p[i].x)!=find(p[i].y)) cnt++,unionn(p[i].x,p[i].y,0),sp.push_back(p[i]);
else A.push_back(p[i]),B.push_back(p[i]);
}
else
{
if (find(p[i].x)!=find(p[i].y)) cnt++,unionn(p[i].x,p[i].y,0);
if (p[i].y<=mid) A.push_back(p[i]);
B.push_back(p[i]);
}
}
for (int i=1;i<=cnt;++i) undo();
cnt=0;
for (int i=0;i<sp.size();++i) cnt++,unionn(sp[i].x,sp[i].y,1);
p.clear(),p.shrink_to_fit(),sp.clear(),sp.shrink_to_fit(),calc(l,mid,A),calc(mid+1,r,B),A.clear(),A.shrink_to_fit(),B.clear(),B.shrink_to_fit();
for (int i=1;i<=cnt;++i) undo();
return;
}
int main()
{
int l,r,x;
vector<reads>p;
n=read(),m=read(),C=read(),maxp[0]=inf;
for (int i=2;i<=n;++i) x=read(),add_edge(x,i);
depth[1]=1,dfs(1);
for (int i=1;i<=n;++i) wp[i]=i,sl[i]=-inf,sr[i]=inf,used[i]=0;
sort(wp+1,wp+n+1,cmp);
for (int i=1;i<=n;++i) rk[wp[i]]=i;
srt=0,smz=n,get_rt(1),solve(srt);
for (int i=1;i<=m;++i) l=read(),r=read(),v[r].push_back((rds){i,l});
for (int i=1;i<=n;++i)
{
if (sl[i]!=-inf) tong[++length]=(reads){sl[i],i};
if (sr[i]!=inf) tong[++length]=(reads){i,sr[i]};
}
sort(tong+1,tong+length+1);
for (int i=1;i<=length;++i) p.push_back(tong[i]);
for (int i=1;i<=n;++i) rt[i]=i;
calc(1,n,p);
for (int i=1;i<=m;++i) printf("%d\n",ans[i]);
return 0;
}
詳細信息
Subtask #1:
score: 4
Accepted
Test #1:
score: 4
Accepted
time: 0ms
memory: 17944kb
input:
100 100 10 16 5 18 28 97 69 43 75 61 17 49 40 52 82 11 48 94 3 12 62 63 89 20 23 33 72 51 39 19 37 10 60 31 14 4 36 100 27 76 46 88 78 45 15 35 99 30 86 38 77 96 34 84 79 90 3 54 95 87 73 50 25 9 80 81 57 2 71 29 83 6 53 66 68 42 1 7 47 67 58 59 93 13 70 65 91 64 98 26 74 22 85 55 41 21 44 8 24 32 5...
output:
1 1 1 4 4 4 1 2 1 3 3 1 4 3 1 1 1 1 4 2 2 1 3 1 1 2 2 2 2 2 4 2 4 3 1 4 3 1 1 1 1 4 1 2 4 1 1 1 3 1 2 1 3 5 2 1 1 1 3 1 1 1 1 1 1 1 2 3 2 1 1 1 4 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 3 3 1 1 1 1 4 3 1 2 2 1
result:
ok 100 numbers
Subtask #2:
score: 4
Accepted
Test #2:
score: 4
Accepted
time: 1417ms
memory: 118708kb
input:
300000 600000 299999 54689 163735 190742 294221 59884 139917 96072 2577 78182 823 116367 142307 60808 79158 165576 16795 133183 293293 135566 178321 178838 276793 25254 199292 283980 166691 6950 151813 30260 153594 41853 22418 97099 60279 251545 287861 176463 15943 257315 25750 64891 238782 215012 2...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 600000 numbers
Subtask #3:
score: 16
Accepted
Test #3:
score: 16
Accepted
time: 1408ms
memory: 117428kb
input:
300000 600000 299900 275908 242561 279434 22147 22850 44627 185131 271000 115019 266044 181265 178564 72508 38997 236987 37465 154831 290467 136480 149628 245773 187248 46113 167958 99170 31088 248444 154173 47163 66859 195090 89740 83929 77842 109147 142120 55954 131989 296566 107565 4488 208098 22...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 600000 numbers
Test #4:
score: 0
Accepted
time: 1391ms
memory: 203664kb
input:
300000 600000 299900 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ...
output:
2 2 2 1 1 2 1 2 2 1 2 2 2 1 1 2 2 2 2 1 2 2 2 2 2 1 2 2 2 1 2 2 2 1 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 1 2 1 2 1 1 2 2 1 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 1 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 1 2 2 2 1 2 2 2 2 1 2 1 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 1 ...
result:
ok 600000 numbers
Test #5:
score: 0
Accepted
time: 1359ms
memory: 197456kb
input:
300000 600000 299900 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ...
output:
2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 1 2 2 2 1 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 1 2 2 1 2 2 2 1 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 1 2 2 1 2 2 2 1 1 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 ...
result:
ok 600000 numbers
Test #6:
score: 0
Accepted
time: 1322ms
memory: 210512kb
input:
300000 600000 299900 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 600000 numbers
Test #7:
score: 0
Accepted
time: 1373ms
memory: 198904kb
input:
300000 600000 299900 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 600000 numbers
Subtask #4:
score: 4
Accepted
Test #8:
score: 4
Accepted
time: 1322ms
memory: 103540kb
input:
300000 600000 1 196208 212926 148911 130413 285394 299608 174690 194347 296651 63048 190567 129371 5945 153445 80159 113039 190233 298862 146033 3972 154693 236257 259021 129019 165652 73964 30809 178090 157090 70227 262652 271457 11819 262122 10301 47927 282407 102319 230866 105104 134969 152272 15...
output:
75104 72984 63343 73236 72434 56813 53012 74300 70738 34588 74932 49561 53549 71797 50762 72758 54608 74307 74860 21190 67335 72138 72905 71753 75047 49298 66847 51122 39223 54306 37778 53327 74551 73268 74211 63480 2887 72370 16737 40356 40616 39828 61654 74740 62374 21338 72975 68226 53927 70971 5...
result:
ok 600000 numbers
Subtask #5:
score: 8
Accepted
Dependency #4:
100%
Accepted
Test #9:
score: 8
Accepted
time: 642ms
memory: 119192kb
input:
300000 600000 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
5 3 2 3 4 4 6 3 2 4 2 5 1 2 4 4 3 3 2 1 2 5 5 3 5 1 3 4 2 2 5 2 4 5 3 4 1 3 3 4 4 1 2 2 4 1 1 4 5 3 5 1 3 1 2 2 5 2 2 2 1 1 2 6 4 3 4 3 4 3 2 2 2 5 2 3 2 3 4 2 3 2 760 4 5 1 2 2 2 4 4 2 3 4 3 3 2 4 4 5 1 5 1 2 1 3 237 4 3 2 3 4 5 4 4 2 3 1 3 1357 2 5 3 3 5 1 5 1 4 4 2 3 454 5 2 2 5 4 3 1587 5 1 2 3 ...
result:
ok 600000 numbers
Test #10:
score: 0
Accepted
time: 1715ms
memory: 108820kb
input:
300000 600000 2 73480 73510 212 841 73399 502 328 414 304 73479 691 73582 469 704 901 225 201 553 73608 591 158 321 144 73648 802 73590 73635 731 641 234 73457 73558 73444 73672 514 272 73381 25 73458 336 614 667 229 178 154 73476 73580 381 405 592 73583 73593 73482 73465 751 580 323 404 821 73433 8...
output:
20669 11930 20705 17982 4880 14243 25608 15296 6249 5143 8545 23515 26033 18641 23263 20068 11915 14609 6293 11010 20548 23083 23276 14224 18857 20957 22273 10707 15016 14642 16720 15294 17380 16489 8386 13207 15012 15102 13212 9876 23833 16246 22159 464 21022 14490 14851 21161 19284 19448 19631 135...
result:
ok 600000 numbers
Subtask #6:
score: 8
Accepted
Dependency #5:
100%
Accepted
Test #11:
score: 8
Accepted
time: 805ms
memory: 119244kb
input:
300000 600000 2 1 95895 95895 1 95895 1 1 95895 95895 95895 1 95895 95895 1 95895 95895 95895 95895 1 95895 95895 1 1 1 1 1 1 1 95895 95895 1 95895 1 95895 1 95895 1 95895 95895 95895 95895 1 95895 1 95895 95895 95895 95895 95895 95895 95895 1 95895 1 1 95895 1 95895 95895 1 95895 1 1 95895 95895 1 ...
output:
39 39 35 31 2 41 14 33 13 12 25 48 34 30 36 4 28 30 17 42 35 42 53 39 38 46 44 34 31 54 40 28 43 36 33 8 43 42 27 27 32 6 29 11 19 39 43 71 35 29 16 35 39 6 35 48 7 36 35 3 24 41 47 19 42 30 49 39 35 41 29 24 2 28 37 37 32 25 31 29 35 3 32 29 38 32 35 38 37 24 12 41 35 32 33 47 32 32 14 36 39 30 21 ...
result:
ok 600000 numbers
Test #12:
score: 0
Accepted
time: 1834ms
memory: 110556kb
input:
300000 600000 3 112999 113964 2257 2947 3134 115717 113542 114722 115764 113009 114462 1322 113810 115981 115838 115200 115619 763 113436 114281 318 112867 2901 2322 131 114608 3231 112860 113698 2579 115276 2515 1754 176 114509 115611 114137 205 112578 114227 2723 115920 115906 71 112725 113093 113...
output:
9620 784 14341 3831 3737 12890 10761 18758 17060 17111 18905 5781 18259 3364 14506 5071 16929 9577 8637 16258 17954 17371 2440 14733 15606 13591 16136 5178 18074 7630 4330 3878 12858 17142 11179 4615 10511 17279 15983 9138 16221 13739 13158 16929 15374 16291 16993 18047 12404 10568 13267 14787 18188...
result:
ok 600000 numbers
Subtask #7:
score: 8
Accepted
Dependency #6:
100%
Accepted
Test #13:
score: 8
Accepted
time: 778ms
memory: 119540kb
input:
300000 600000 2 69598 58726 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927...
output:
127 129 227 314 111 76 56 79 18 70 46 67 13 71 3 48 49 204 11 126 61 30 111 32 87 43 99 65 45 276 112 141 35 64 74 87 174 44 64 129 137 165 318 80 32 232 315 129 29 49 68 148 49 249 180 96 185 76 165 132 157 49 287 68 226 52 37 41 91 53 9 140 97 14 43 8 158 70 17 39 75 138 90 45 49 280 127 299 33 25...
result:
ok 600000 numbers
Test #14:
score: 0
Accepted
time: 1914ms
memory: 112004kb
input:
300000 600000 4 996 263 503 262714 634 815 262012 263087 892 359 262090 262098 929 262451 216 262296 504 262187 261892 672 261889 262994 216 409 262651 240497 311 261757 398 503 60 262769 639 854 261730 610 733 570 219400 418 182 143 261845 126 261742 115 143 468 103 310 993 262557 731 600 262496 35...
output:
6733 4647 3401 168 3116 9706 4453 2150 9447 6231 6910 6924 7526 10053 9653 2767 7067 6456 8779 1167 8235 2113 8929 8434 1621 9086 10689 4930 7852 6626 3305 9008 4797 5084 5374 9051 7443 2809 9217 4703 3420 2826 7442 9893 8721 4000 3324 8244 10025 8303 7535 9278 5940 345 10060 7471 6582 8207 7073 888...
result:
ok 600000 numbers
Subtask #8:
score: 8
Accepted
Test #15:
score: 8
Accepted
time: 541ms
memory: 55012kb
input:
100000 100000 7 3 87695 6 4 7 2 10 51981 85695 13 85698 22473 33773 14 15 75237 20 18 35318 22 23 19 67326 26 24 30 56391 84768 84771 33 34 32 84484 37 17018 36 39 91935 42 43 44 45 41 65104 40 51 25723 52 5250 17947 48 24228 58 59 55 56 57 53 61 64 63 84776 62 60 24088 69 45861 68 82869 82870 77 72...
output:
3367 3131 1643 3371 1904 3754 3619 1930 2574 1758 685 3622 1805 2280 3823 2221 1982 2419 1233 2922 2826 3271 2805 1046 959 3645 1057 3741 1239 2631 996 3733 2907 400 1033 3227 3308 3156 3278 2773 3324 2236 3688 3413 2999 3735 3006 3371 1401 2415 1433 3236 3745 3328 3383 1977 619 3416 3757 3187 2766 ...
result:
ok 100000 numbers
Test #16:
score: 0
Accepted
time: 505ms
memory: 55504kb
input:
100000 100000 12 11 45267 5 45264 2 10 4 7 6308 9 6 16 6547 13 14 15 17 20 18 22 24 21 26 23 27 29 55168 45460 56028 35 34 48824 36 33 38 31 37 44 47 42 47456 45 40 41 39 43 53 58 49 23719 57 83266 59 48 96221 50 96229 55 63 62 39642 61 60 96558 96555 71 73 72 69 74 68 68996 70 71957 78 86 84 85 81 ...
output:
1745 1142 820 1401 1 1288 1629 1465 953 1741 291 1116 1464 2085 2047 1712 1727 2098 94 2095 1125 513 1439 1540 1840 415 174 548 2127 999 399 2050 2163 2035 1447 1550 1914 686 2098 1420 2162 1934 2114 1962 938 950 941 2165 2087 1834 1587 1338 996 1687 2143 530 1219 905 584 2040 1402 1085 1536 1695 19...
result:
ok 100000 numbers
Test #17:
score: 0
Accepted
time: 429ms
memory: 56180kb
input:
100000 100000 234 97 119 71 133 42 132 154 130 143 58 92 4 160 90 124 48 51 39 34 14 114 120 99 113 84 38 127 98 60 88 140 109 8 31 53 138 76 129 57 148 73 107 46 91 13 150 131 72 145 26 79 29 32 134 158 159 104 52 75840 77 121 85 115 110 23 70 40 16 93 24 68 100 61 161 41 33 20 86 157 144 152 54 49...
output:
94 60 94 97 85 13 76 77 113 100 96 33 106 106 61 62 75 70 39 89 86 49 101 24 32 6 49 38 68 83 56 78 26 108 52 62 43 105 75 110 74 35 52 10 36 112 75 29 73 82 95 72 35 89 18 14 59 8 79 4 97 33 96 106 27 80 53 107 42 32 37 69 61 14 88 79 71 104 99 102 90 43 71 32 29 105 94 91 63 105 29 91 105 30 20 10...
result:
ok 100000 numbers
Test #18:
score: 0
Accepted
time: 454ms
memory: 56148kb
input:
100000 100000 1152 1018 860 558 245 582 14 91 900 364 898 825 569 928 667 77 657 205 607 101 743 398 133 1023 649 858 965 389 805 207 354 637 451 179 862 14926 213 785 420 1059 218 393 812 787 1017 1027 377 118 712 37 156 820 694 70 588 376 408 261 214 148 546 313 385 36 770 799 796 792 269 367 606 ...
output:
12 17 15 14 13 2 21 19 22 13 14 23 21 21 21 17 24 12 8 3 26 10 21 19 13 7 26 25 10 27 19 8 21 1 8 13 13 5 6 27 24 26 28 26 9 2 15 18 11 13 22 20 7 5 15 19 26 8 3 6 19 11 22 20 22 1 6 21 18 25 19 22 11 23 26 5 8 2 6 23 23 7 13 28 13 25 21 21 8 2 18 14 26 8 21 26 13 26 22 12 11 26 22 6 23 20 2 23 21 8...
result:
ok 100000 numbers
Test #19:
score: 0
Accepted
time: 508ms
memory: 56148kb
input:
100000 100000 10133 392 523 127 156 339 402 529 521 281 625 324 310 93 151 499 136 372 29 53 333 641 217 429 166 137 112 592 569 580 362 636 586 461 543 247 388 474 512 239 623 326 661 181 185 227 31 330 176 198 659 441 645 254 540 169 261 489 68 456 215 342 343 299 444 492 646 195 133 146 532 211 2...
output:
4 3 1 3 2 4 1 3 4 4 3 3 2 2 3 2 1 3 2 1 3 3 2 2 1 3 1 1 1 2 4 1 2 2 4 3 2 1 2 2 4 2 2 2 2 1 4 3 2 4 2 2 3 2 4 2 2 2 3 2 2 2 1 3 2 2 4 1 1 2 2 3 4 3 1 1 2 1 3 3 2 3 2 1 2 2 2 1 4 1 1 1 4 1 3 1 4 3 4 3 1 3 3 2 3 3 1 2 1 2 4 3 2 4 4 2 4 2 2 1 1 1 2 3 1 1 4 4 3 3 2 2 2 2 1 2 3 4 2 1 3 2 3 3 2 2 4 2 3 3 ...
result:
ok 100000 numbers
Subtask #9:
score: 0
Time Limit Exceeded
Dependency #8:
100%
Accepted
Test #20:
score: 0
Time Limit Exceeded
input:
300000 600000 7 6 4 38447 2 3 10 12 26878 134369 8 13 26876 255212 255210 19 183423 16 21 22 20 17 24 110798 262581 25 29 157966 28 31 138382 70996 36 30 33 34 188791 37 143928 42 44 46 234913 43 40 41 56433 47 48 53 281329 50 263638 57 56 229029 55 54 163950 62 48562 61 65 63 66 111250 64 67 73 134...
output:
6188 10902 11172 7292 10083 8712 6431 7252 11017 10862 10416 5821 5216 639 10502 5665 5763 80 11203 11201 8937 10338 11160 8599 10334 2921 10819 10899 4144 10401 11194 1705 8289 9398 7890 7648 7340 10160 3797 4079 4208 11032 10336 9413 11244 7664 228 820 4446 9217 11076 9039 10666 3276 7282 6807 112...
result:
Subtask #10:
score: 0
Time Limit Exceeded
Test #25:
score: 8
Accepted
time: 1791ms
memory: 104856kb
input:
300000 300000 5 629 447 2259 86 1828 1091 1344 2291 159549 1641 2079 227 2606 82 1557 1459 159826 2194 746 2599 1979 2439 2669 2199 2623 969 902 158016 275 1552 1174 1841 831 2127 267 159933 1340 159184 1389 172 2330 563 1986 1265 1199 1747 158872 1355 94 1915 2407 1771 151 796 1083 1624 2023 2189 4...
output:
5635 6408 6420 59 5606 1971 5869 6120 2701 3851 4341 4652 5350 5995 4514 5829 5097 3907 4409 5517 5609 1153 3429 5038 6505 4737 5241 5517 5577 5045 6263 1099 5688 6439 6263 5294 2144 3760 5934 6581 509 5478 6276 4914 4173 1790 3911 6528 5967 6314 6612 4917 4383 5751 6014 6599 4305 6894 1712 4800 579...
result:
ok 300000 numbers
Test #26:
score: 0
Accepted
time: 1744ms
memory: 109748kb
input:
300000 300000 12 161 248 932 984 1509 2098 1935 1374 118418 1136 1610 1056 997 1357 1879 953 1500 932 1685 2165 120655 118195 183 75 1935 1645 237 681 415 814 1155 1976 120 1032 1004 1817 1105 837 2192 525 119315 178 1397 1816 1581 119138 120709 826 1999 268 922 1354 1335 1907 101 119483 116 2174 91...
output:
1302 1402 50 1437 162 754 1513 479 981 647 792 598 1209 1049 50 1412 849 132 1029 294 804 1520 1155 1029 151 1339 924 1630 1362 1714 901 973 304 663 1473 632 1217 1221 1382 1329 278 123 1288 488 1213 1294 1330 536 909 992 1166 871 702 701 713 665 621 1264 1033 507 254 1008 1216 1498 887 1223 1190 26...
result:
ok 300000 numbers
Test #27:
score: -8
Time Limit Exceeded
input:
300000 300000 913 39 985 406 634 753 1026 380 1095 36 460 840 725 114 820 83 715 162 271 1087 1021 72 567 622 612 694 306 915 488 69 429 649 782 954 204 1045 560 175 745 1022 621 452 914 507 529 736 1096 592 1038 851 12 393 768 872 665 522 731 381 1085 184 1032 407 328 933 1013 202 312 281 17 841 88...
output:
1 1 39 33 2 13 40 17 2 64 41 2 35 31 39 27 43 5 1 13 31 35 1 30 40 1 2 27 26 5 17 31 31 1 1 41 40 27 31 31 46 1 41 41 2 5 1 31 40 27 17 1 41 1 46 40 17 5 43 1 1 5 1 1 35 31 31 17 1 46 31 6 42 6 1 27 41 41 2 6 40 1 34 39 34 41 64 1 40 1 35 1 27 35 27 31 1 1 40 1 21 40 31 1 30 17 31 1 35 21 2 40 41 39...
result:
Subtask #11:
score: 4
Accepted
Test #28:
score: 4
Accepted
time: 1996ms
memory: 132604kb
input:
300000 300000 5 258453 2 159342 6 4 5 17931 8 9 161038 11 14 15 16 136403 13 224782 21 22 118484 19 25 23 215708 28 2995 29 27 49288 32 33 30 224227 234280 37 35 39 128732 66005 40 110386 44 48020 43 45 50 51 47 48 223892 55 52 53 35958 250021 58 108355 60 57 240112 51602 62 66 292618 65 236914 69 7...
output:
14320 4150 13774 14884 14577 1969 12529 12799 7247 2639 10663 14120 11225 14801 8687 1215 13398 3028 15017 14709 5840 3816 11774 14234 12930 11184 12985 11011 10341 11966 8886 13194 14589 12575 14819 14952 10137 4690 14667 7667 12106 1480 4288 11431 6861 15052 12932 13603 4072 14767 1653 14253 6759 ...
result:
ok 300000 numbers
Test #29:
score: 0
Accepted
time: 1671ms
memory: 134916kb
input:
300000 300000 14 9 10 5 8 3 6 11 7 4 295545 15 132914 13 14 17 12 143751 18 23 29 21 28 27 187583 20 26 25 31 22 24 30 36 37 38 39 552 33 34 41 47 40 46 43 296950 49 48 45 42 276580 55 57 51 53 62 52 54 60 50 59 58 61 47115 67 69 65 37906 64 68 81 78 73 157912 71 76 79 72 82 80 70 74 77 92 86 87 94 ...
output:
4772 4685 3029 43 5154 5071 3435 3269 4867 5053 5201 2618 3259 2418 3998 3693 1188 3975 4981 4872 2710 3266 1019 4268 5227 563 4429 2336 4238 1708 2223 5192 4904 3791 5143 5157 5089 4142 4643 3013 1967 5069 1309 442 4447 4370 2363 4854 4822 4339 4945 5222 1593 4806 3947 2617 4104 4739 1633 426 4521 ...
result:
ok 300000 numbers
Test #30:
score: 0
Accepted
time: 1436ms
memory: 138752kb
input:
300000 300000 73 32 26 31 36 224351 34 20 11 35 8 3 30 22 23 13 7 14 29 18 38 21 5 28 12 16 4 27 9 37 17 10 25 15 19 6 2 24 73 50 70 52 83 82 72 89 44 40 43 98 71 58 67 76 68 81 49 91 100 55 77 57 101 51 78 64 48 39 88 53 93 42 62 46 96 94 97 80 45 86 74 85 66 90 79 54 59 41 92 47 153391 75 95 87 56...
output:
954 5 956 959 962 801 952 949 843 969 559 961 167 362 862 531 526 930 537 691 394 956 303 766 882 241 522 265 284 195 239 855 928 885 808 240 347 283 972 196 41 899 133 78 107 96 524 39 962 757 936 233 887 836 553 508 945 874 741 826 104 545 911 231 504 952 957 117 848 909 173 771 658 734 270 856 87...
result:
ok 300000 numbers
Test #31:
score: 0
Accepted
time: 1443ms
memory: 138288kb
input:
300000 300000 246 57 140868 19 42 32 34 9 58 47 5 11 28 59 16 18 60 31 56 24 72 20 43 71 6 17 8 15 44 53 21 14 51 13 27 49 45 3 64 68 10 61 4 50 73 69 25 74 52 66 29 46 41 63 22 55 12 7 70 62 67 65 2 38 35 48 23 36 33 39 40 30 54 26 170 115 85 138 161 102 80 182 143 88 171 173 267 124 241 279 92 218...
output:
292 239 54 290 108 201 245 283 9 248 13 249 142 260 74 295 247 253 186 121 6 2 41 198 275 67 21 253 6 277 242 257 187 88 281 122 40 207 198 56 56 209 18 282 107 248 172 272 293 258 283 119 234 241 47 272 16 138 230 200 286 257 267 92 50 174 157 149 294 230 242 285 150 49 8 125 287 252 131 303 196 30...
result:
ok 300000 numbers
Test #32:
score: 0
Accepted
time: 1634ms
memory: 138672kb
input:
300000 300000 5189 1543 1762 4137 149 837 3686 3560 4947 1374 2059 3475 2996 519 4309 295 350 552 4216 299 2078 1776 5033 1463 3160 601 1552 4528 1591 1076 1489 5080 117 3805 1514 467 4282 4676 1010 2269 4480 4921 3544 3988 222 3017 2363 4492 720 1408 5075 4674 255 1353 1598 628 3956 4915 4671 4396 ...
output:
3 10 4 1 15 13 9 4 9 5 7 15 16 11 10 12 13 13 5 12 15 15 14 13 1 14 8 9 11 3 4 8 12 12 11 15 13 14 3 11 6 10 13 2 2 12 14 1 4 2 11 12 6 4 3 3 5 3 14 13 12 9 12 3 2 13 6 11 15 5 6 12 13 5 13 11 1 16 8 4 9 14 9 4 3 14 5 10 10 10 12 11 5 13 9 2 15 3 4 4 12 3 13 4 8 9 4 12 2 9 6 7 15 10 14 11 15 7 12 9 ...
result:
ok 300000 numbers
Subtask #12:
score: 8
Accepted
Dependency #8:
100%
Accepted
Test #33:
score: 8
Accepted
time: 535ms
memory: 47356kb
input:
100000 200000 2 9 8 7 7 14 95519 95518 95518 23 23 25 16 95520 25 95520 18 95517 18 24171 14 9 95519 8 95517 717 2416 3320 3271 2217 2034 3573 2197 73 1695 3185 2521 2049 3247 802 470 2335 3259 1627 3188 585 731 1699 1238 662 3264 62279 1075 1664 128 3423 724 2378 3279 1863 2369 3183 1713 1023 3562 ...
output:
11691 5679 17564 8045 16858 13929 4012 3605 15055 3590 13753 14754 20784 6850 4359 6640 15561 16897 12208 19640 15772 2734 19046 8135 15724 19225 20126 3209 18438 19172 8212 18179 4535 10158 6197 4773 17167 15600 8334 10816 19745 14144 2834 17878 5347 19026 19300 5140 1527 10885 7656 5766 13005 1261...
result:
ok 200000 numbers
Test #34:
score: 0
Accepted
time: 519ms
memory: 48288kb
input:
100000 200000 6 51 91345 38 50 91263 76 81 91267 42 76 74 61 117 54 109 91291 91248 59 50 98 58 91245 91335 75 81 91328 102 27 91326 59 72 76 98 47 70 91325 91305 91279 91273 3 91311 97 106 85 91273 91308 85 91341 91342 91290 107 81 91321 91333 91350 68 91252 91251 91313 91291 101 49 59 82 71 9 9133...
output:
1070 439 723 599 559 730 1030 1482 1012 1059 805 1763 1079 1271 866 1765 1764 1292 1397 1400 1104 883 457 1686 606 1208 947 514 1687 723 306 444 811 251 1364 683 1066 1076 1099 1062 598 1038 1067 1208 1034 762 940 374 214 63 724 1465 1683 687 1136 1689 1239 1116 1019 1759 1894 610 1449 759 799 416 8...
result:
ok 200000 numbers
Test #35:
score: 0
Accepted
time: 513ms
memory: 49064kb
input:
100000 200000 21 38 821 256 2166 1759 611 1227 2761 1837 2741 902 2172 2428 2246 2080 686 2576 2414 1026 1366 2163 1490 2734 2120 40083 2813 765 40304 931 1514 2170 26 1305 381 1635 2992 693 3112 1016 2648 2016 1008 2437 2114 1739 39718 972 699 40248 2402 2050 1841 1782 2327 298 40166 2057 40588 162...
output:
273 294 225 284 397 62 253 275 292 285 341 350 195 183 392 84 235 301 229 328 134 318 261 182 237 79 305 152 298 216 210 256 392 251 246 189 118 328 189 239 79 325 233 155 390 284 245 83 38 252 243 279 112 75 312 57 152 292 412 228 267 314 303 196 229 336 181 138 271 103 281 322 288 294 397 344 75 1...
result:
ok 200000 numbers
Test #36:
score: 0
Accepted
time: 478ms
memory: 50752kb
input:
100000 200000 213 1159 1216 876 1075 1420 2048 831 1776 1282 150 562 1933 1182 17119 1627 826 748 1242 1814 1390 2040 1801 1018 1769 16206 96 642 1915 1772 776 900 234 10 348 1082 1030 1005 2002 1853 1389 369 1162 1561 1713 1967 2000 1490 412 761 1036 123 161 427 1418 75 709 1502 1664 411 686 1480 2...
output:
8 42 37 48 39 20 30 39 66 57 31 45 9 57 23 22 47 26 44 37 53 33 30 13 51 46 41 14 61 54 45 45 44 14 46 60 43 42 31 14 52 18 28 14 42 25 21 35 41 51 42 38 36 28 29 52 50 20 63 12 24 49 56 46 24 29 42 24 43 46 29 22 55 36 42 52 50 23 38 51 31 46 28 48 27 14 31 60 41 5 23 50 47 36 34 11 17 49 42 57 26 ...
result:
ok 200000 numbers
Subtask #13:
score: 8
Accepted
Dependency #12:
100%
Accepted
Test #37:
score: 8
Accepted
time: 1074ms
memory: 77312kb
input:
200000 400000 2 199739 199741 199744 199742 199742 199741 199739 199744 507 137654 137562 137624 1547 2628 2639 137604 572 2330 973 216 353 1924 1007 137625 2923 254 2061 689 137670 1241 925 765 137860 2613 138 1042 1850 137896 796 2907 1128 659 138009 1417 2204 511 418 137608 157898 137649 603 1223...
output:
31016 4487 6621 12637 32791 28499 19990 38914 2238 16303 37074 6172 9856 39049 1350 33325 6997 39112 21189 37628 6462 24859 793 2168 6564 18381 14277 2191 22743 14910 7663 21739 38810 38148 32615 36758 9929 6320 33110 4216 38692 24437 15391 23948 31216 2771 31903 35959 18895 15963 10783 37943 5441 1...
result:
ok 400000 numbers
Test #38:
score: 0
Accepted
time: 1159ms
memory: 79468kb
input:
200000 400000 6 55999 537 56078 368 7 465 171 514 35 391 430 180 391 480 407 379 171 359 437 221 138 461 199 153 194 252 213 33 88 135 98 81 2 31 56211 348 305 392 81 392 257 276 512 529 56 74 549 236 149 529 454 424 329 544 325 231 534 62 10 233 167 254 219 411 174 508 56238 120 155 56528 142 56225...
output:
2537 1878 2765 2542 3267 2890 3187 1084 3524 966 3057 1780 2985 1873 2992 3306 3154 3236 2465 3474 3049 1790 1085 2636 2496 3544 3385 1948 3170 3243 1029 1691 2357 2546 1808 3268 2118 3514 2349 3506 3176 1628 3372 2186 3191 1153 2634 2735 2483 1594 3681 3365 2917 1104 1998 3484 2481 2971 2162 3226 2...
result:
ok 400000 numbers
Test #39:
score: 0
Accepted
time: 1186ms
memory: 80664kb
input:
200000 400000 21 7982 449 499 3066 2718 458 3293 7498 4024 339 5055 8275 3687 2643 436 4597 6605 7291 1149 2925 4378 529 6834 1470 6939 7005 472 7714 7583 308 4438 7413 7343 1743 3021 8415 4859 7781 1302 4881 790 6406 7959 1158 5385 5092 2060 8246 4278 4544 5178 2580 7306 4457 5153 4284 437 5198 758...
output:
782 486 764 273 625 814 850 312 986 689 502 718 380 98 905 718 327 655 97 79 388 786 829 603 715 188 376 442 613 619 548 467 593 655 695 336 794 884 465 620 451 757 432 111 320 467 343 383 510 557 101 563 320 638 441 665 376 657 493 681 478 547 473 128 235 502 442 271 431 274 128 196 804 537 956 757...
result:
ok 400000 numbers
Test #40:
score: 0
Accepted
time: 1045ms
memory: 83392kb
input:
200000 400000 213 780 401 942 1329 1289 566 1010 206 1115 1140 529 945 163 1086 649 282 420 1192 1091 113 233 474 915 132 480 582 880 15 925 1332 584 749 27 516 1363 142 271 704 1280 348 508 1439 1341 1184 120 466 6459 1458 1502 1101 931 124 1112 860 1462 312 781 1190 1321 23 590 138 998 281 812 56 ...
output:
69 94 52 120 76 98 105 49 95 102 108 29 78 41 88 91 80 65 37 65 108 52 50 97 78 77 118 33 119 99 90 114 76 72 74 102 112 112 60 40 21 118 67 38 110 52 67 21 93 108 15 98 18 90 94 100 105 111 86 80 116 67 37 82 18 106 54 119 96 40 90 112 66 103 60 7 110 30 95 16 22 81 95 123 114 112 72 86 65 101 93 9...
result:
ok 400000 numbers
Subtask #14:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Dependency #7:
100%
Accepted
Dependency #8:
100%
Accepted
Dependency #9:
0%