QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#650748 | #2099. Rendezvous | test123 | 100 ✓ | 406ms | 55112kb | C++14 | 2.7kb | 2024-10-18 16:21:40 | 2024-10-18 16:21:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn=500005;
int read(){
int ret=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
while( isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch&15);ch=getchar();}
return ret*f;
}
int n,m;
int ot[maxn],du[maxn],top[maxn],que[maxn],fa[maxn][20],len[maxn],dis[maxn];
bool vis[maxn];
void get(int now){
if(top[now]) return ;
if(!top[ot[now]]) get(ot[now]);
top[now]=top[ot[now]];
dis[now]=dis[ot[now]]+1;
return ;
}
void Topo(){
int hed=0,til=0;
for(int i=1;i<=n;++i) if(!du[i]) que[++til]=i;
while(hed<til){
int now=que[++hed];
if(!--du[ot[now]]){
que[++til]=ot[now];
}
}
for(int i=1;i<=n;++i){
if(du[i]){
top[i]=i;
fa[i][0]=i;
}else{
fa[i][0]=ot[i];
}
}
for(int i=1;i<=n;++i) if(!top[i]) get(i);
}
void DFS(int now,int fr,int d){
if(now==fr){
len[now]=d;
return ;
}
dis[now]=d;top[now]=fr;
vis[now]=1;
DFS(ot[now],fr,d+1);
}
void solve(int u,int v){
int fu=top[u],fv=top[v];
if(fu==fv&&!vis[u]&&!vis[v]){
int x=0,y=0;
if(dis[u]>dis[v]){
for(int t=19;~t;--t){
if(vis[fa[u][t]]) continue;
if(dis[fa[u][t]]>dis[v]){
u=fa[u][t];
x+=(1<<t);
}
}
u=fa[u][0];
x++;
}
if(dis[v]>dis[u]){
for(int t=19;~t;--t){
if(vis[fa[v][t]]) continue;
if(dis[fa[v][t]]>dis[u]){
v=fa[v][t];
y+=(1<<t);
}
}
v=fa[v][0];
y++;
}
if(u==v){
printf("%d %d\n",x,y);
return ;
}
for(int t=19;~t;--t){
if(fa[u][t]!=fa[v][t]){
u=fa[u][t];x+=(1<<t);
v=fa[v][t];y+=(1<<t);
}
}
u=fa[u][0];x++;
v=fa[v][0];y++;
printf("%d %d\n",x,y);
}else{
if(top[fu]!=top[fv]){
printf("-1 -1\n");
return ;
}else{
if(vis[u]) fu=u;
if(vis[v]) fv=v;
int x=0,y=0,wx=dis[fv]-dis[fu],wy=dis[fu]-dis[fv],t=top[fu];
if(!vis[u]) x=dis[u];
if(!vis[v]) y=dis[v];
if(wx<0) wx+=len[t];
if(wy<0) wy+=len[t];
if(max(x+wx,y)<max(x,y+wy)){
printf("%d %d\n",x+wx,y);
return ;
}
if(max(x+wx,y)>max(x,y+wy)){
printf("%d %d\n",x,y+wy);
return ;
}
if(min(x+wx,y)<min(x,y+wy)){
printf("%d %d\n",x+wx,y);
return ;
}
if(min(x+wx,y)>min(x,y+wy)){
printf("%d %d\n",x,y+wy);
return ;
}
printf("%d %d\n",x+wx,y);
}
}
}
int main(){
n=read();m=read();
for(int i=1;i<=n;++i){
ot[i]=read();
du[ot[i]]++;
}
Topo();
for(int t=1;t<=19;++t){
for(int i=1;i<=n;++i){
fa[i][t]=fa[fa[i][t-1]][t-1];
}
}
for(int i=1;i<=n;++i){
if(du[i]&&!vis[i]){
vis[i]=1;
DFS(ot[i],i,1);
}
}
while(m--){
int u=read(),v=read();
solve(u,v);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 2ms
memory: 14056kb
input:
3 5 2 1 3 1 2 2 1 1 1 2 2 3 2
output:
1 0 1 0 0 0 0 0 -1 -1
result:
ok 5 lines
Test #2:
score: 10
Accepted
time: 2ms
memory: 14176kb
input:
1 2 1 1 1 1 1
output:
0 0 0 0
result:
ok 2 lines
Subtask #2:
score: 10
Accepted
Test #3:
score: 10
Accepted
time: 0ms
memory: 16036kb
input:
9 4 8 1 1 2 2 3 3 9 1 9 3 2 8 5 7 6 8
output:
1 1 2 0 2 2 2 2
result:
ok 4 lines
Test #4:
score: 10
Accepted
time: 2ms
memory: 14040kb
input:
4 2 2 3 4 1 4 2 2 4
output:
2 0 2 0
result:
ok 2 lines
Subtask #3:
score: 10
Accepted
Test #5:
score: 10
Accepted
time: 0ms
memory: 14060kb
input:
1000 1000 1 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 97 98 99 ...
output:
254 1 300 0 0 0 126 0 266 0 224 2 1 300 0 316 27 0 1 117 92 0 2 649 228 0 11 1 0 479 158 0 406 1 315 1 0 486 1 212 353 1 492 0 533 0 560 0 420 0 0 204 0 47 412 0 0 58 0 17 409 0 0 181 10 0 4 372 22 0 519 0 1 543 0 474 20 0 140 0 0 264 0 255 0 96 0 25 188 1 0 337 0 181 0 151 0 189 278 0 589 0 350 1 3...
result:
ok 1000 lines
Test #6:
score: 10
Accepted
time: 2ms
memory: 14048kb
input:
1000 1000 750 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 97 98 9...
output:
1 291 122 0 0 232 194 0 75 0 0 366 1 87 83 0 356 1 258 0 1 118 136 0 0 136 0 252 0 182 309 0 285 2 0 303 205 0 137 0 0 355 0 295 0 372 1 245 0 102 0 287 316 0 0 146 0 328 1 301 1 104 219 0 104 0 0 127 0 89 336 0 1 135 85 0 126 0 0 128 0 239 0 301 1 116 0 138 0 169 35 0 0 164 105 0 1 182 0 6 0 223 13...
result:
ok 1000 lines
Test #7:
score: 10
Accepted
time: 0ms
memory: 16084kb
input:
1000 1000 2 3 4 1 1 5 1 7 10 11 9 10 9 13 3 15 748 668 206 461 418 106 38 633 31 256 229 616 34 825 245 143 831 737 549 135 103 802 87 439 477 983 946 53 759 260 14 715 684 350 413 524 750 696 185 988 43 562 844 638 591 626 610 267 748 722 539 322 377 468 291 450 595 672 882 585 282 744 92 1000 257 ...
output:
2 2 2 2 1 1 1 1 2 0 2 0 2 0 0 2 1 0 0 1 0 0 0 0 4 2 4 2 3 1 3 1 1 3 3 1 2 0 0 2 2 2 2 2 -1 -1 -1 -1 -1 -1 -1 -1 5 16 -1 -1 -1 -1 18 21 -1 -1 8 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 20 13 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 23 19 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 2...
result:
ok 1000 lines
Test #8:
score: 10
Accepted
time: 0ms
memory: 16168kb
input:
12 5 4 3 5 5 1 1 12 12 9 9 7 1 12 12 9 9 1 1 3 1 12 2
output:
0 0 0 0 0 0 2 0 1 3
result:
ok 5 lines
Subtask #4:
score: 10
Accepted
Test #9:
score: 10
Accepted
time: 0ms
memory: 16228kb
input:
2000 2000 1 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 97 98 99 ...
output:
0 82 667 0 0 1256 1 1035 701 0 0 666 0 1226 444 0 0 553 829 0 0 172 364 0 747 2 0 325 597 0 0 200 0 635 0 489 145 0 186 0 2 90 499 0 0 1126 0 152 0 449 212 0 952 2 0 18 196 1 0 505 1 1234 0 299 859 0 1103 0 1 305 125 1 852 1 1270 0 0 906 0 83 74 0 192 0 0 13 0 756 46 0 1281 0 523 0 450 0 350 0 3 462...
result:
ok 2000 lines
Test #10:
score: 10
Accepted
time: 2ms
memory: 14116kb
input:
2000 2000 1500 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 97 98 ...
output:
41 0 1 649 666 0 0 225 45 1 0 246 515 0 0 721 428 1 0 342 1 38 0 13 0 408 0 348 1 159 0 490 0 707 1 92 515 2 447 1 711 0 345 0 596 0 1 245 1 164 0 618 595 0 0 148 1 648 0 234 1 473 306 1 524 0 1 375 531 0 181 0 0 42 0 197 1 629 68 0 499 0 0 228 0 77 0 717 0 625 401 0 483 1 1 494 654 1 122 0 438 0 34...
result:
ok 2000 lines
Test #11:
score: 10
Accepted
time: 0ms
memory: 16108kb
input:
2000 2000 2 3 4 1 1 5 1 7 10 11 9 10 9 13 3 15 84 1321 110 805 1766 811 1287 340 684 847 1377 1889 1384 1029 1770 708 1581 1386 1088 1775 1687 1603 607 1217 486 916 803 599 1361 898 1129 939 1786 1965 1252 1247 571 1313 1962 283 402 742 1212 1725 1390 933 889 1346 951 562 997 1317 734 467 1432 1788 ...
output:
2 2 2 2 1 1 1 1 2 0 2 0 2 0 0 2 1 0 0 1 0 0 0 0 4 2 4 2 3 1 3 1 1 3 3 1 2 0 0 2 2 2 2 2 -1 -1 -1 -1 57 2 -1 -1 5 26 24 23 -1 -1 -1 -1 -1 -1 -1 -1 5 58 9 13 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 35 8 21 20 24 15 11 48 14 4 43 27 21 32 5 -1 -1 -1 -1 -1 -1 24 16 -1 -1 23 22 14 19 -1 -1 -1 -1 -1 -1 -1 -1 6 42...
result:
ok 2000 lines
Test #12:
score: 10
Accepted
time: 2ms
memory: 16044kb
input:
10 5 2 3 4 5 1 4 6 7 2 9 10 8 8 10 8 5 4 1 8 4
output:
4 3 3 4 4 0 2 0 3 0
result:
ok 5 lines
Subtask #5:
score: 10
Accepted
Test #13:
score: 10
Accepted
time: 25ms
memory: 20340kb
input:
50000 50000 1 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 97 98 9...
output:
11123 0 0 15621 4869 0 18488 0 0 22137 2 11273 27923 0 0 28385 0 5673 29619 0 11577 0 428 0 0 17411 0 7605 23948 0 31229 0 2265 0 0 19843 0 11004 0 27327 4767 0 9504 0 0 15837 0 11635 8388 0 317 1 1 4392 0 3201 26181 0 10880 0 23382 0 9856 0 16363 0 0 21415 0 10472 22784 0 0 6301 2715 0 16227 0 3776...
result:
ok 50000 lines
Test #14:
score: 10
Accepted
time: 9ms
memory: 20452kb
input:
50000 50000 37500 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 97 ...
output:
1 5126 12786 0 0 5952 18513 0 0 8634 11892 0 1 17188 7941 0 0 18442 1 10714 0 5722 7548 1 5954 0 16209 1 1 5957 4923 1 2286 0 0 16411 5106 0 4756 0 0 16923 1790 0 0 14825 17635 1 13898 0 4358 0 0 18730 1933 0 14881 0 2447 0 18249 0 0 9425 0 18330 0 9162 16984 0 0 17728 7690 0 0 13721 11625 0 0 6717 ...
result:
ok 50000 lines
Test #15:
score: 10
Accepted
time: 5ms
memory: 20444kb
input:
50000 50000 2 3 4 1 1 5 1 7 10 11 9 10 9 13 3 15 5018 5972 2530 23775 7367 8210 39635 6577 7456 20586 31030 8434 29471 1945 10210 24672 46859 24882 19545 27240 13237 41813 5136 42689 9252 9088 37440 49636 4153 37618 22566 28516 23167 3593 7846 7110 6366 46741 6756 9243 30092 42653 19670 31172 35075 ...
output:
2 2 2 2 1 1 1 1 2 0 2 0 2 0 0 2 1 0 0 1 0 0 0 0 4 2 4 2 3 1 3 1 1 3 3 1 2 0 0 2 2 2 2 2 -1 -1 -1 -1 -1 -1 -1 -1 255 237 -1 -1 67 50 14 40 292 252 -1 -1 -1 -1 -1 -1 116 110 -1 -1 253 376 373 231 376 248 -1 -1 56 124 23 71 -1 -1 -1 -1 34 156 174 271 39 146 -1 -1 237 134 58 44 -1 -1 -1 -1 -1 -1 3 135 9...
result:
ok 50000 lines
Test #16:
score: 10
Accepted
time: 2ms
memory: 16164kb
input:
1000 1000 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 1...
output:
3 3 3 3 3 3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 4 3 3 3 3 4 3 3 3 2 4 2 2 2 3 3 3 3 3 2 3 3 3 2 3 3 3 3 4 3 4 3 3 3 3 3 3 3 2 2 1 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 2 3 3 3 2 2 3 3 3 3 3 3 3 3 2 1 3 3 4 3 3 2 3 4 3 3 3 3 3 3 3 3 2 3 3 3 4 3 4 3 3 3 3 3 2 2 3 3 3 3 3 4 3 3 4 3 3 3 3 3 3 3 3 4 3 3 3 3 3 3 3 3 3 3 ...
result:
ok 1000 lines
Subtask #6:
score: 10
Accepted
Test #17:
score: 10
Accepted
time: 47ms
memory: 24356kb
input:
100000 100000 1 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 97 98...
output:
0 43234 1 39186 0 15650 0 27262 13752 2 0 20173 2866 1 65643 1 0 61325 0 25264 46862 2 48744 1 50490 2 14290 0 0 55707 4028 0 0 53164 10613 0 1 2071 0 55038 0 41511 9798 0 28961 0 0 3171 1 13563 16183 0 0 13566 47996 1 602 0 8788 0 0 38685 0 40823 22450 0 43322 0 0 58441 0 459 59683 0 16555 0 22963 ...
result:
ok 100000 lines
Test #18:
score: 10
Accepted
time: 26ms
memory: 24752kb
input:
100000 100000 75000 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 9...
output:
31895 0 21813 0 0 26968 22018 1 0 36675 1 22074 0 21016 30619 0 6060 0 0 14937 6526 0 18512 0 0 20761 0 2742 8275 0 4106 1 0 6651 8839 0 0 28481 0 9588 5349 0 19601 0 0 33309 29399 1 0 1144 19293 0 0 25566 21303 0 36285 3 23446 0 16826 0 32645 0 0 6814 0 29309 1 12715 17116 0 19690 0 0 7599 0 5217 7...
result:
ok 100000 lines
Test #19:
score: 10
Accepted
time: 33ms
memory: 24716kb
input:
100000 100000 2 3 4 1 1 5 1 7 10 11 9 10 9 13 3 15 15542 46331 32703 78285 29126 87592 43804 53346 11032 8830 94934 18509 38510 46730 38183 28246 50047 82206 48463 31712 64387 4008 27852 74869 37651 14820 96643 59442 69407 37731 8775 86369 47841 71857 26829 98077 55907 8349 85951 1357 47589 16548 87...
output:
2 2 2 2 1 1 1 1 2 0 2 0 2 0 0 2 1 0 0 1 0 0 0 0 4 2 4 2 3 1 3 1 1 3 3 1 2 0 0 2 2 2 2 2 -1 -1 -1 -1 185 150 390 196 194 152 264 209 99 29 160 176 41 29 42 238 236 274 -1 -1 193 49 -1 -1 21 27 210 60 140 56 348 279 36 156 240 335 199 241 -1 -1 71 171 177 141 -1 -1 154 43 349 250 219 185 354 77 115 20...
result:
ok 100000 lines
Subtask #7:
score: 10
Accepted
Test #20:
score: 10
Accepted
time: 120ms
memory: 33320kb
input:
200000 200000 1 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 97 98...
output:
62087 0 0 20011 51937 0 0 67296 30492 0 0 48923 12764 1 92412 0 93735 0 28216 0 2 125101 60998 0 0 118603 0 17071 1 89385 0 61764 0 25302 0 65348 0 53286 47603 0 110899 0 0 92226 23530 0 12342 0 97631 0 0 4081 0 2381 0 53712 13749 0 0 133697 0 214 0 5306 122335 0 56259 1 0 61025 24867 0 0 2601 0 722...
result:
ok 200000 lines
Test #21:
score: 10
Accepted
time: 54ms
memory: 33416kb
input:
200000 200000 150000 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:
55766 0 41872 0 60665 0 37485 0 64868 1 10147 0 23797 1 2 17941 20773 1 1 71207 0 41604 0 38145 26943 0 44379 0 1 69595 49478 1 29215 0 0 57396 0 17881 0 46808 51024 1 0 1679 0 38043 0 63805 0 50739 0 44515 26764 0 49581 0 66704 1 0 2755 0 29568 72528 0 31888 1 0 56962 6361 0 51323 0 0 19243 64818 0...
result:
ok 200000 lines
Test #22:
score: 10
Accepted
time: 85ms
memory: 33100kb
input:
200000 200000 2 3 4 1 1 5 1 7 10 11 9 10 9 13 3 15 72206 35684 176405 185564 117052 174852 124088 58517 151577 95614 83377 106770 144834 168556 193061 179396 93120 139928 152689 128624 75709 62274 177123 85264 48186 138466 112854 131234 130886 50338 46697 147143 58654 182039 105971 29871 58330 42942...
output:
2 2 2 2 1 1 1 1 2 0 2 0 2 0 0 2 1 0 0 1 0 0 0 0 4 2 4 2 3 1 3 1 1 3 3 1 2 0 0 2 2 2 2 2 -1 -1 -1 -1 390 772 601 165 583 325 169 39 421 162 226 195 351 65 211 751 174 894 971 176 193 443 55 231 215 599 162 3 165 604 427 246 146 454 56 525 25 471 -1 -1 5 950 79 48 370 467 122 181 276 135 648 337 775 9...
result:
ok 200000 lines
Subtask #8:
score: 10
Accepted
Test #23:
score: 10
Accepted
time: 221ms
memory: 54584kb
input:
500000 250000 1 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 97 98...
output:
0 213563 0 196437 171535 0 41008 0 0 129379 98492 0 0 69501 0 119011 0 38318 17439 0 0 22496 0 76283 299089 2 1866 0 12596 0 29713 0 119480 0 0 46786 0 50804 0 65783 0 157392 0 131830 137 2 0 2150 1 4170 1 173523 0 192995 0 76085 46332 0 2 16847 0 305356 128283 2 0 216782 0 32545 46275 0 0 148777 0 ...
result:
ok 250000 lines
Test #24:
score: 10
Accepted
time: 96ms
memory: 54912kb
input:
500000 250000 375000 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:
0 91707 1 29378 180901 0 118803 1 0 369 35532 0 71943 0 132485 0 0 46099 127243 0 1 9762 0 38923 0 23823 0 166894 1 67682 51142 0 0 149970 0 61089 183952 0 173631 0 0 120962 143523 0 0 28532 32339 0 0 146648 53840 1 8249 0 0 24747 0 174427 2 135335 1 115755 0 68035 26043 0 139204 0 41474 0 0 114803 ...
result:
ok 250000 lines
Test #25:
score: 10
Accepted
time: 140ms
memory: 55040kb
input:
500000 250000 2 3 4 1 1 5 1 7 10 11 9 10 9 13 3 15 44861 465253 397571 84678 44232 461372 15873 371606 232621 59561 465536 122650 402708 407415 105652 84019 353648 263223 151469 132847 382707 422722 260975 412882 340190 443025 109171 425560 328370 36931 90185 40051 20450 19654 250634 125360 429432 3...
output:
2 2 2 2 1 1 1 1 2 0 2 0 2 0 0 2 1 0 0 1 0 0 0 0 4 2 4 2 3 1 3 1 1 3 3 1 2 0 0 2 2 2 2 2 -1 -1 -1 -1 10 1040 646 1653 700 784 35 973 24 403 -1 -1 -1 -1 321 894 70 258 456 156 -1 -1 22 700 751 496 949 859 351 437 -1 -1 1057 87 36 102 454 87 53 370 334 70 1779 782 142 603 667 65 162 149 178 905 124 35 ...
result:
ok 250000 lines
Subtask #9:
score: 10
Accepted
Test #26:
score: 10
Accepted
time: 406ms
memory: 54524kb
input:
500000 500000 1 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 97 98...
output:
0 112498 2 44159 213343 0 105855 0 144738 0 0 235901 145446 0 95320 0 0 51074 1 199132 0 75826 161209 0 292629 0 0 131838 1 60562 2332 0 0 4186 0 324325 144072 1 150169 0 1 123412 45924 0 76061 0 261352 0 0 229460 0 163166 0 224459 85346 1 0 240298 0 289952 1 60485 27021 0 1 109027 156480 0 1 96635 ...
result:
ok 500000 lines
Test #27:
score: 10
Accepted
time: 131ms
memory: 53852kb
input:
500000 500000 375000 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:
177870 1 1 143791 9941 0 1 72395 1 138586 0 183221 0 116436 0 137904 0 160453 0 58406 173125 0 116096 0 169093 0 0 173884 72501 0 0 87247 0 59010 178474 0 184230 0 127167 0 151274 0 0 166025 0 65162 0 83036 159804 0 0 85355 0 155299 33394 0 96105 1 10258 1 136241 0 184821 0 51320 0 127123 0 1816 0 4...
result:
ok 500000 lines
Test #28:
score: 10
Accepted
time: 230ms
memory: 55112kb
input:
500000 500000 2 3 4 1 1 5 1 7 10 11 9 10 9 13 3 15 388337 170136 14128 137458 346611 251535 412578 475441 486806 135085 132339 385860 43708 312800 329999 268980 361249 430243 182813 427055 73035 364894 468155 196770 218620 2235 56977 316743 321327 174470 78696 259335 158768 159178 325300 316265 2934...
output:
2 2 2 2 1 1 1 1 2 0 2 0 2 0 0 2 1 0 0 1 0 0 0 0 4 2 4 2 3 1 3 1 1 3 3 1 2 0 0 2 2 2 2 2 -1 -1 -1 -1 552 520 964 177 -1 -1 1360 97 -1 -1 -1 -1 -1 -1 226 155 -1 -1 -1 -1 65 303 -1 -1 1353 219 -1 -1 -1 -1 467 351 133 105 224 256 350 793 146 652 69 612 -1 -1 834 109 31 1136 463 319 157 916 164 145 950 2...
result:
ok 500000 lines
Subtask #10:
score: 10
Accepted
Test #29:
score: 10
Accepted
time: 390ms
memory: 54536kb
input:
500000 500000 1 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 97 98...
output:
0 19102 10535 0 781 0 0 102259 3 66322 1 14994 0 46817 108065 0 5653 0 0 164623 101939 0 0 166180 0 6618 0 210035 63983 0 2 61788 46608 0 103447 0 150310 1 79195 1 1 97171 0 172 224836 0 0 188981 0 11476 0 89485 0 342066 3 9581 145313 0 195041 0 0 28606 0 341478 0 123048 1 85434 91533 1 170728 1 165...
result:
ok 500000 lines
Test #30:
score: 10
Accepted
time: 128ms
memory: 54956kb
input:
500000 500000 375000 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 5815 146545 0 0 174875 4265 0 0 93036 156093 0 155920 1 0 127438 1 64153 1 26561 0 170410 0 96581 35996 0 69007 0 146537 1 0 78359 0 90591 1 39385 0 101273 109040 1 0 94647 0 77480 0 77636 0 90499 1 121281 179276 0 0 128556 86545 0 5311 0 1 172769 23310 0 0 40708 2 79069 0 96557 169101 0 1 122510 ...
result:
ok 500000 lines
Test #31:
score: 10
Accepted
time: 174ms
memory: 54812kb
input:
500000 500000 2 3 4 1 1 5 1 7 10 11 9 10 9 13 3 15 311342 100898 332060 174333 309794 444408 202662 87358 18068 174748 347076 47777 385981 60362 77232 114952 124822 88326 15398 21529 346996 308972 302661 245058 194077 314837 265692 144278 277248 56491 339886 54212 294488 244381 144075 255630 52268 4...
output:
2 2 2 2 1 1 1 1 2 0 2 0 2 0 0 2 1 0 0 1 0 0 0 0 4 2 4 2 3 1 3 1 1 3 3 1 2 0 0 2 2 2 2 2 -1 -1 -1 -1 589 193 19 614 265 346 -1 -1 1108 354 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 24 -1 -1 48 197 -1 -1 -1 -1 -1 -1 -1 -1 62 1024 -1 -1 543 441 162 311 -1 -1 -1 -1 14 205 -1 -1 -1 -1 225 215 -1 -1 455 465 396 54 ...
result:
ok 500000 lines
Extra Test:
score: 0
Extra Test Passed