QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#109768 | #6396. Puzzle: Kusabi | KING_OF_TURTLE | AC ✓ | 44ms | 28168kb | C++14 | 2.0kb | 2023-05-30 16:10:31 | 2023-05-30 16:10:42 |
Judging History
answer
#include<bits/stdc++.h>
#define pii pair<int,int>
#define pb emplace_back
using namespace std;
const int N=1000005;
struct edge{
int v,nxt;
}e[N*2];
int d[N],n,head[N],cnt,a[N],flag=1;char ch[10];
vector<pii> ans;
void adde(int u,int v)
{e[++cnt].v=v;e[cnt].nxt=head[u];head[u]=cnt;}
int dp[N],c[N][4];
void dfs(int u,int fa)
{
vector<int> v1,v2,v3;
d[u]=d[fa]+1;++c[u][a[u]];
if(a[u]==1)v1.push_back(u);
if(a[u]==2)v2.push_back(u);
if(a[u]==3)v3.push_back(u);
for(int i=head[u];i;i=e[i].nxt)
{
int v=e[i].v;dfs(v,u);
if(a[dp[v]]==1)v1.push_back(dp[v]);
if(a[dp[v]]==2)v2.push_back(dp[v]);
if(a[dp[v]]==3)v3.push_back(dp[v]);
for(int j=0;j<4;++j)c[u][j]+=c[v][j];
}
if(!flag)return;
if(abs(c[u][1]-c[u][2])>=2){flag=0;return;}
if(c[u][1]!=c[u][2]&&(c[u][3]&1)){flag=0;return;}
sort(v1.begin(),v1.end(),[&](const int u,const int v){return d[u]<d[v];});
sort(v2.begin(),v2.end(),[&](const int u,const int v){return d[u]<d[v];});
sort(v3.begin(),v3.end(),[&](const int u,const int v){return d[u]<d[v];});
for(int i=0;i<v3.size();i+=2)
{
if(i==v3.size()-1){dp[u]=v3[i];break;}
if(d[v3[i]]!=d[v3[i+1]])dp[u]=v3[i],++i;
ans.pb(v3[i],v3[i+1]);
}
if(c[u][1]>c[u][2])
{
int l=v1.size()-1,r=v2.size()-1;
while(l>=0||r>=0)
{
if(l>=0&&r>=0&&d[v1[l]]<d[v2[r]])
{ans.pb(v1[l],v2[r]);--l;--r;}
else if(!dp[u]&&l>=0)dp[u]=v1[l],--l;
else {flag=0;return;}
}
}
else
{
int l=0,r=0;
while(l<v1.size()||r<v2.size())
{
if(l<v1.size()&&r<v2.size()&&d[v1[l]]<d[v2[r]])
{ans.pb(v1[l],v2[r]);++l;++r;}
else if(!dp[u]&&r<v2.size())dp[u]=v2[r],++r;
else {flag=0;return;}
}
}
}
int main()
{
scanf("%d",&n);
for(int i=1,u,v;i<n;++i)
{
scanf("%d%d%s",&u,&v,ch);adde(v,u);
if(ch[0]=='D')a[u]=1;
if(ch[0]=='C')a[u]=2;
if(ch[0]=='T')a[u]=3;
if(ch[0]=='-')a[u]=0;
}
dfs(1,0);if(dp[1])flag=0;
if(!flag)puts("NO");
else
{
puts("YES");
for(auto p:ans)printf("%d %d\n",p.first,p.second);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 7816kb
input:
8 2 1 - 3 1 - 4 2 Tong 5 2 Tong 6 3 Duan 7 3 - 8 7 Chang
output:
YES 6 8 5 4
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 2ms
memory: 3624kb
input:
10 2 1 Duan 3 2 Duan 4 2 - 5 4 Chang 6 2 Chang 7 1 Duan 8 6 Tong 9 6 Tong 10 3 Chang
output:
YES 9 8 3 10 2 6 7 5
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
2 2 1 Tong
output:
NO
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 29ms
memory: 10376kb
input:
100000 2 1 Duan 3 1 Duan 4 3 - 5 4 Duan 6 3 - 7 4 Duan 8 4 - 9 8 - 10 7 Duan 11 9 - 12 7 Duan 13 7 Duan 14 8 Duan 15 13 - 16 10 Duan 17 11 Duan 18 12 - 19 1 Duan 20 5 Duan 21 4 Duan 22 14 Duan 23 16 - 24 22 Duan 25 16 Duan 26 13 - 27 13 - 28 17 - 29 5 Duan 30 22 - 31 23 - 32 9 Duan 33 5 - 34 30 Duan...
output:
YES 78961 61327 79617 28763 25684 40169 25045 49361 24156 60228 50185 97603 56901 72206 10579 41848 73900 76635 50152 73042 25325 47346 63312 91464 79886 91034 53651 27084 10551 20428 36927 98200 69283 80157 68167 78977 10332 33135 40003 87866 10300 10826 81993 83126 63025 61240 51469 32742 26924 33...
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 25ms
memory: 9344kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 4 - 7 6 - 8 7 - 9 5 - 10 9 - 11 10 - 12 6 - 13 12 - 14 11 - 15 9 - 16 14 - 17 16 - 18 10 - 19 15 - 20 13 - 21 20 - 22 17 - 23 22 - 24 22 Duan 25 11 - 26 12 - 27 20 - 28 18 - 29 28 - 30 16 - 31 28 - 32 30 - 33 31 - 34 28 - 35 34 - 36 35 - 37 22 - 38 34 - 39 38 - 40 35...
output:
YES 54260 61365 66883 94528 52379 80746 25539 57632 70587 86270 10692 50931 46038 46315 3973 51215 40468 42355 28057 31649 73329 57657 26291 66814 21998 29098 45470 93763 54966 84353 41071 74078 25774 30942 59287 51936 9388 82007 8527 40293 57690 97856 67337 76507 76115 58992 90319 76631 51620 86905...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 32ms
memory: 7764kb
input:
100000 2 1 - 3 2 - 4 3 Duan 5 4 Chang 6 5 Duan 7 6 Chang 8 7 Duan 9 8 Chang 10 9 Duan 11 10 Chang 12 11 Duan 13 12 Chang 14 12 Duan 15 14 Chang 16 15 Tong 17 15 Tong 18 17 Duan 19 18 Duan 20 19 Chang 21 18 Duan 22 21 Duan 23 18 Chang 24 21 - 25 24 Duan 26 25 Chang 27 26 Duan 28 27 Chang 29 26 Duan 3...
output:
YES 31 37 40 42 64 68 173 203 150 196 771 820 744 777 803 809 799 810 552 778 528 556 374 446 345 423 772 920 570 708 524 510 649 682 588 610 660 652 397 587 396 433 291 503 641 686 549 645 529 536 429 478 321 348 286 294 284 323 282 316 279 307 341 376 501 530 1152 1160 1446 1757 1435 1685 1428 141...
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 26ms
memory: 7764kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 - 7 6 - 8 7 - 9 8 - 10 9 Duan 11 10 - 12 11 Chang 13 12 Duan 14 13 Chang 15 14 - 16 15 - 17 16 Duan 18 17 Chang 19 17 - 20 19 - 21 20 - 22 21 - 23 22 - 24 23 - 25 24 - 26 25 Duan 27 26 - 28 27 Duan 29 28 - 30 29 Chang 31 28 - 32 31 Chang 33 32 - 34 32 - 35 34 - 36 ...
output:
YES 126 131 174 185 197 216 173 189 163 181 151 160 138 144 169 199 207 218 223 255 287 290 262 260 291 359 489 545 362 372 320 468 306 315 286 279 244 247 603 660 758 809 784 902 708 762 751 786 746 779 663 775 756 763 658 716 589 675 648 686 566 591 582 613 621 655 643 711 579 562 560 628 577 690 ...
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 26ms
memory: 7880kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 Duan 7 6 - 8 7 - 9 8 - 10 9 Chang 11 10 - 12 11 Duan 13 12 Chang 14 13 - 15 14 Duan 16 15 Chang 17 16 - 18 17 - 19 18 Duan 20 19 - 21 20 - 22 21 - 23 22 Chang 24 23 - 25 24 Duan 26 25 - 27 26 Chang 28 27 - 29 28 - 30 29 - 31 30 Duan 32 31 - 33 32 - 34 33 - 35 34 - ...
output:
YES 155 161 249 251 277 292 430 424 368 381 383 353 380 386 429 422 490 493 528 532 526 545 534 551 531 540 555 556 661 665 641 642 639 650 638 646 622 624 621 625 612 614 627 630 615 629 598 609 700 706 718 725 786 820 873 875 835 852 903 909 857 865 850 866 802 813 801 810 770 772 696 698 694 780 ...
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 28ms
memory: 8188kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 Duan 7 6 - 8 7 - 9 8 Chang 10 9 - 11 10 Duan 12 11 - 13 12 Chang 14 13 Duan 15 14 - 16 15 Chang 17 16 - 18 17 Duan 19 18 - 20 19 Chang 21 20 Duan 22 21 Chang 23 22 - 24 23 Duan 25 24 Chang 26 25 Duan 27 26 - 28 27 - 29 28 Chang 30 29 Duan 31 30 Chang 32 31 - 33 32 ...
output:
YES 306 308 356 357 450 453 554 556 549 552 547 548 568 570 567 569 676 682 671 672 738 737 728 735 801 805 794 806 791 793 908 910 914 922 946 952 991 1004 1011 1016 1014 1024 1156 1164 1153 1160 1151 1155 1140 1147 1097 1102 1095 1094 1089 1093 1075 1076 1122 1123 1125 1129 1134 1135 1157 1154 114...
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 11ms
memory: 8748kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 - 7 6 - 8 7 - 9 8 - 10 9 - 11 10 - 12 11 - 13 12 - 14 13 - 15 14 - 16 15 - 17 16 - 18 17 - 19 18 - 20 19 - 21 20 - 22 21 - 23 22 - 24 23 - 25 24 - 26 25 - 27 26 - 28 27 - 29 28 - 30 29 - 31 30 - 32 31 - 33 32 - 34 33 - 35 34 - 36 35 - 37 36 - 38 37 - 39 38 - 40 39 ...
output:
YES 4758 4774 11802 12004 12701 12878 14425 14403 15095 15175 16218 16272 15803 15813 15960 16111 17698 17703 18616 18828 20479 20553 22709 22767 24981 25371 23807 24571 23319 23781 28570 28616 26536 27425 29047 29756 29822 30157 29383 29413 35551 35528 34775 34909 33210 34774 33062 33101 39240 3988...
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 27ms
memory: 7632kb
input:
100000 2 1 - 3 1 - 4 2 - 5 1 - 6 1 - 7 2 Duan 8 4 - 9 1 - 10 1 - 11 2 - 12 2 - 13 2 - 14 6 - 15 1 - 16 6 - 17 1 - 18 5 - 19 1 - 20 1 - 21 2 - 22 8 - 23 6 - 24 1 - 25 4 Duan 26 1 - 27 10 - 28 1 - 29 8 - 30 5 - 31 7 - 32 2 - 33 3 - 34 12 - 35 3 - 36 1 - 37 12 - 38 8 - 39 8 - 40 1 - 41 4 - 42 16 - 43 8...
output:
YES 71252 68260 93199 72829 11262 59385 7114 56366 21981 56413 88219 85882 70420 69070 70961 46636 70919 24045 8534 53558 6776 51312 47483 14730 8121 66745 42970 14466 3305 66071 37873 86329 12867 85723 39119 31531 82602 56430 24828 87213 40456 67836 34098 99956 87387 17961 91017 87569 73357 68937 6...
result:
ok Correct.
Test #12:
score: 0
Accepted
time: 33ms
memory: 7536kb
input:
100000 2 1 - 3 1 - 4 1 - 5 1 - 6 1 - 7 1 - 8 1 - 9 1 - 10 3 - 11 1 - 12 2 - 13 2 - 14 2 - 15 1 - 16 2 - 17 2 - 18 1 - 19 1 - 20 1 - 21 2 - 22 1 - 23 2 - 24 2 - 25 1 - 26 1 - 27 4 - 28 1 - 29 2 - 30 3 - 31 1 - 32 10 - 33 6 - 34 4 - 35 1 - 36 2 Duan 37 1 - 38 4 - 39 10 - 40 1 - 41 1 - 42 3 - 43 6 - 44...
output:
YES 89903 67589 2731 25532 68594 39272 84767 81476 71809 60781 98218 45615 13863 9592 41771 38360 67278 32307 98634 46144 36895 70045 56597 90229 87249 21515 44881 7445 70645 99328 12870 44757 15488 70229 38942 68314 361 31755 62803 53849 72268 74966 42791 38644 69049 39590 60607 31128 24390 68719 7...
result:
ok Correct.
Test #13:
score: 0
Accepted
time: 28ms
memory: 7412kb
input:
100000 2 1 Duan 3 1 Duan 4 1 Duan 5 1 Duan 6 1 Duan 7 1 - 8 1 Duan 9 1 Duan 10 1 - 11 1 Duan 12 1 - 13 1 Duan 14 1 Duan 15 1 Duan 16 1 Duan 17 1 Duan 18 2 - 19 1 Duan 20 1 Duan 21 2 - 22 2 Duan 23 1 Duan 24 1 Duan 25 1 Duan 26 1 Duan 27 2 Duan 28 1 Duan 29 2 Duan 30 1 Duan 31 2 Duan 32 1 - 33 1 Duan...
output:
YES 14629 99565 8043 58177 8022 77249 7886 99568 7106 97191 6452 79782 6438 98265 73953 52710 6320 76068 5888 84889 5812 81286 65693 41217 5668 97669 5312 65081 92388 77289 74586 71711 5206 89733 4798 79262 4777 99789 98851 84855 79617 72776 4736 67208 96692 91965 4470 58017 93682 82143 99395 98993 ...
result:
ok Correct.
Test #14:
score: 0
Accepted
time: 22ms
memory: 7336kb
input:
100000 2 1 - 3 1 - 4 1 - 5 1 - 6 1 - 7 1 - 8 1 - 9 1 - 10 1 - 11 1 - 12 1 - 13 1 Duan 14 1 - 15 1 - 16 1 - 17 1 - 18 1 - 19 1 - 20 1 - 21 1 - 22 1 - 23 1 - 24 1 - 25 1 - 26 1 - 27 1 - 28 1 - 29 1 Duan 30 1 - 31 1 - 32 2 Duan 33 1 - 34 1 - 35 1 Duan 36 1 - 37 1 - 38 1 - 39 1 - 40 1 - 41 1 - 42 1 - 43...
output:
YES 3382 85599 3013 95392 81526 79392 90600 76883 2266 47562 92236 67095 2087 82645 94655 86680 83294 83119 98104 53700 1891 59880 94429 84824 1867 38939 86276 72196 1851 74866 1832 73841 82555 75982 52187 33013 84502 60149 94488 90018 89910 77895 1798 87531 1780 62543 50707 45755 96747 63884 96811 ...
result:
ok Correct.
Test #15:
score: 0
Accepted
time: 23ms
memory: 7308kb
input:
100000 2 1 Duan 3 1 - 4 1 - 5 1 Duan 6 1 - 7 1 - 8 1 - 9 1 - 10 1 - 11 1 - 12 1 - 13 1 - 14 1 - 15 1 - 16 1 - 17 1 - 18 1 - 19 1 - 20 1 - 21 1 - 22 1 - 23 1 - 24 1 - 25 1 - 26 1 - 27 1 - 28 1 - 29 1 - 30 1 - 31 1 - 32 1 - 33 1 Duan 34 1 - 35 1 - 36 1 - 37 1 - 38 1 - 39 1 - 40 1 - 41 1 - 42 1 - 43 1 ...
output:
YES 1484 93600 1226 65492 80577 54647 98136 87425 1057 92548 95875 90647 91502 88522 864 65449 78454 63757 863 57780 91133 79380 859 90975 94837 81087 93397 69230 847 63165 841 88299 96200 91139 83594 61658 81529 67080 96779 96324 99215 74882 99293 99183 87893 56495 778 78381 81594 44807 767 82056 7...
result:
ok Correct.
Test #16:
score: 0
Accepted
time: 22ms
memory: 7372kb
input:
100000 2 1 Duan 3 1 Duan 4 1 - 5 1 Duan 6 1 - 7 1 Duan 8 1 Duan 9 1 Duan 10 1 Duan 11 1 - 12 1 - 13 1 - 14 1 Duan 15 1 Duan 16 1 Duan 17 1 - 18 1 Duan 19 1 Duan 20 1 Duan 21 1 - 22 1 - 23 1 Duan 24 1 Duan 25 1 Duan 26 1 - 27 1 - 28 1 Duan 29 1 Duan 30 1 - 31 1 Duan 32 1 Duan 33 1 - 34 1 Duan 35 1 - ...
output:
YES 705 83464 622 95111 575 99954 92518 91152 99688 93861 531 92449 528 71582 524 66385 518 91774 96388 95679 502 95051 495 68161 491 92051 79514 71560 486 91617 466 92920 456 94768 86414 82066 71375 69375 455 94412 451 96222 92101 86461 99900 97252 437 86105 436 78526 90094 65746 93000 82699 430 84...
result:
ok Correct.
Test #17:
score: 0
Accepted
time: 26ms
memory: 7652kb
input:
100000 2 1 - 3 1 - 4 2 - 5 2 - 6 2 Duan 7 3 - 8 1 - 9 1 - 10 6 - 11 3 - 12 2 - 13 7 - 14 1 - 15 9 - 16 11 - 17 13 - 18 9 - 19 16 - 20 19 - 21 8 - 22 5 - 23 14 - 24 21 - 25 21 - 26 16 - 27 5 - 28 5 - 29 19 - 30 8 - 31 24 - 32 30 - 33 12 Duan 34 9 - 35 12 Duan 36 6 - 37 15 - 38 26 - 39 29 - 40 13 - 41...
output:
NO
result:
ok Correct.
Test #18:
score: 0
Accepted
time: 25ms
memory: 7468kb
input:
100000 2 1 Duan 3 2 Duan 4 3 - 5 3 Duan 6 4 - 7 4 Duan 8 3 Duan 9 2 - 10 4 Duan 11 8 Duan 12 6 - 13 3 Duan 14 6 Duan 15 7 Duan 16 6 Duan 17 14 Tong 18 7 - 19 16 Duan 20 14 Duan 21 12 Duan 22 20 Duan 23 14 Duan 24 19 - 25 2 Duan 26 22 - 27 24 Duan 28 8 Duan 29 4 Duan 30 23 Duan 31 24 Duan 32 23 Duan ...
output:
NO
result:
ok Correct.
Test #19:
score: 0
Accepted
time: 23ms
memory: 7648kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 - 7 4 - 8 7 - 9 8 - 10 9 - 11 10 Duan 12 9 - 13 12 - 14 12 - 15 10 - 16 8 - 17 13 - 18 10 - 19 14 - 20 13 - 21 19 - 22 19 Duan 23 11 - 24 23 Duan 25 23 - 26 5 - 27 22 - 28 22 Duan 29 17 - 30 29 - 31 29 - 32 17 - 33 27 - 34 33 Duan 35 31 - 36 24 - 37 34 - 38 37 - 39...
output:
NO
result:
ok Correct.
Test #20:
score: 0
Accepted
time: 27ms
memory: 7496kb
input:
100000 2 1 Duan 3 2 Chang 4 3 - 5 4 - 6 5 - 7 6 Duan 8 7 - 9 8 Chang 10 9 Duan 11 10 Chang 12 11 - 13 12 Duan 14 13 Chang 15 13 - 16 15 - 17 15 - 18 15 Duan 19 18 - 20 19 Duan 21 19 Chang 22 20 - 23 22 - 24 21 Duan 25 23 - 26 22 - 27 25 Chang 28 26 - 29 28 Duan 30 24 Chang 31 28 - 32 23 - 33 28 - 34...
output:
NO
result:
ok Correct.
Test #21:
score: 0
Accepted
time: 21ms
memory: 7612kb
input:
100000 2 1 Duan 3 2 Chang 4 3 - 5 4 - 6 5 Duan 7 6 - 8 7 - 9 8 Chang 10 9 Duan 11 10 Chang 12 11 Duan 13 12 Chang 14 12 - 15 14 - 16 15 Duan 17 16 Chang 18 17 - 19 17 Duan 20 19 - 21 19 Chang 22 21 - 23 21 Duan 24 23 Duan 25 24 Chang 26 24 Chang 27 24 Duan 28 27 - 29 28 Chang 30 28 Duan 31 30 - 32 3...
output:
NO
result:
ok Correct.
Test #22:
score: 0
Accepted
time: 23ms
memory: 7368kb
input:
100000 2 1 Duan 3 2 Chang 4 3 Duan 5 4 - 6 5 Chang 7 6 - 8 7 Duan 9 8 - 10 9 Chang 11 10 Duan 12 11 Chang 13 12 - 14 13 Duan 15 14 - 16 15 Chang 17 16 - 18 17 Duan 19 18 - 20 19 - 21 20 - 22 21 Chang 23 22 - 24 23 Duan 25 24 Chang 26 25 - 27 26 Duan 28 27 - 29 28 Chang 30 28 Duan 31 30 - 32 31 Chang...
output:
NO
result:
ok Correct.
Test #23:
score: 0
Accepted
time: 18ms
memory: 8032kb
input:
100000 2 1 Duan 3 2 - 4 3 - 5 4 - 6 5 - 7 6 - 8 7 - 9 8 - 10 9 - 11 10 - 12 11 Chang 13 12 Duan 14 13 - 15 14 - 16 15 Chang 17 16 Duan 18 17 Chang 19 18 - 20 19 - 21 20 - 22 21 - 23 22 - 24 23 - 25 24 - 26 25 Duan 27 26 - 28 27 - 29 28 - 30 29 - 31 30 - 32 31 - 33 32 - 34 33 Chang 35 34 - 36 35 - 37...
output:
NO
result:
ok Correct.
Test #24:
score: 0
Accepted
time: 27ms
memory: 8272kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 Duan 7 6 - 8 7 Chang 9 8 - 10 9 - 11 10 - 12 11 - 13 12 - 14 13 Duan 15 14 - 16 15 Chang 17 16 - 18 17 - 19 18 - 20 19 Duan 21 20 - 22 21 - 23 22 - 24 23 Chang 25 24 - 26 25 Duan 27 26 Chang 28 27 Duan 29 28 - 30 29 - 31 30 - 32 31 Chang 33 32 Duan 34 33 - 35 34 - ...
output:
NO
result:
ok Correct.
Test #25:
score: 0
Accepted
time: 25ms
memory: 7396kb
input:
100000 2 1 Duan 3 1 - 4 1 - 5 1 - 6 3 - 7 2 - 8 2 - 9 4 - 10 1 - 11 2 - 12 3 Duan 13 2 - 14 4 - 15 3 - 16 3 - 17 2 - 18 2 - 19 1 - 20 7 Duan 21 1 - 22 15 - 23 6 - 24 1 - 25 8 - 26 11 - 27 5 - 28 16 - 29 17 - 30 16 - 31 3 - 32 7 - 33 3 Duan 34 7 Duan 35 3 - 36 8 - 37 6 - 38 16 - 39 3 - 40 3 - 41 11 -...
output:
NO
result:
ok Correct.
Test #26:
score: 0
Accepted
time: 19ms
memory: 7472kb
input:
100000 2 1 - 3 1 - 4 1 - 5 1 - 6 1 - 7 1 Duan 8 1 - 9 1 - 10 1 - 11 3 - 12 2 - 13 1 - 14 1 - 15 1 - 16 2 - 17 1 Duan 18 3 - 19 1 - 20 1 Duan 21 8 - 22 2 - 23 3 - 24 3 Duan 25 1 - 26 1 - 27 1 - 28 1 - 29 4 - 30 1 - 31 3 - 32 3 - 33 3 - 34 2 - 35 1 - 36 1 Duan 37 1 - 38 3 - 39 2 - 40 4 - 41 2 Duan 42 ...
output:
NO
result:
ok Correct.
Test #27:
score: 0
Accepted
time: 26ms
memory: 7408kb
input:
100000 2 1 Duan 3 1 Duan 4 1 Duan 5 1 Duan 6 1 Duan 7 1 Duan 8 1 Duan 9 1 Duan 10 1 Duan 11 1 Duan 12 1 Duan 13 1 Duan 14 2 Duan 15 1 Duan 16 1 Duan 17 1 Duan 18 2 Duan 19 1 Duan 20 1 - 21 1 Duan 22 1 Duan 23 1 Duan 24 1 Duan 25 1 Duan 26 1 Duan 27 2 Duan 28 1 Duan 29 1 Duan 30 1 - 31 1 Duan 32 1 Du...
output:
NO
result:
ok Correct.
Test #28:
score: 0
Accepted
time: 10ms
memory: 7268kb
input:
100000 2 1 - 3 1 Duan 4 1 - 5 1 - 6 1 - 7 1 Duan 8 1 - 9 1 Duan 10 1 - 11 1 Duan 12 1 Duan 13 1 Duan 14 1 Duan 15 1 Duan 16 1 - 17 1 Duan 18 1 Duan 19 1 Duan 20 1 Duan 21 1 - 22 1 - 23 1 Duan 24 1 - 25 1 Duan 26 1 Duan 27 1 Duan 28 1 Duan 29 1 Duan 30 1 Duan 31 1 Duan 32 1 - 33 1 - 34 1 Duan 35 1 Du...
output:
NO
result:
ok Correct.
Test #29:
score: 0
Accepted
time: 20ms
memory: 7328kb
input:
100000 2 1 Duan 3 1 Duan 4 1 Duan 5 1 Duan 6 1 Duan 7 1 Duan 8 1 - 9 1 Duan 10 1 Duan 11 1 Duan 12 1 - 13 1 Duan 14 1 Duan 15 1 Duan 16 1 Duan 17 1 Duan 18 1 Duan 19 1 Duan 20 1 - 21 1 - 22 1 Duan 23 1 - 24 1 Duan 25 1 Duan 26 1 Duan 27 1 Duan 28 1 Duan 29 1 Duan 30 1 Duan 31 1 Duan 32 1 Duan 33 1 -...
output:
NO
result:
ok Correct.
Test #30:
score: 0
Accepted
time: 23ms
memory: 7296kb
input:
100000 2 1 Duan 3 1 - 4 1 Duan 5 1 Duan 6 1 Duan 7 1 Duan 8 1 Duan 9 1 Duan 10 1 Duan 11 1 Duan 12 1 Duan 13 1 Duan 14 1 Duan 15 1 Duan 16 1 Duan 17 1 Duan 18 1 Duan 19 1 - 20 1 Duan 21 1 Duan 22 1 Duan 23 1 Duan 24 1 Duan 25 1 Duan 26 1 Duan 27 1 Duan 28 1 - 29 1 Duan 30 1 Duan 31 1 Duan 32 1 - 33 ...
output:
NO
result:
ok Correct.
Test #31:
score: 0
Accepted
time: 25ms
memory: 28168kb
input:
100000 2 1 Duan 3 2 - 4 3 Chang 5 4 - 6 5 Duan 7 6 Chang 8 7 - 9 8 - 10 9 Duan 11 10 Chang 12 11 Duan 13 12 Chang 14 13 Duan 15 14 Chang 16 15 - 17 16 - 18 17 - 19 18 Duan 20 19 - 21 20 - 22 21 Chang 23 22 Duan 24 23 Chang 25 24 - 26 25 Duan 27 26 Chang 28 27 Duan 29 28 - 30 29 Chang 31 30 Duan 32 3...
output:
YES 38668 38669 43573 43574 44575 44576 44896 44897 47954 47955 48086 48087 51731 51732 52698 52699 53051 53053 53843 53844 54079 54080 55169 55170 56247 56248 56590 56591 57028 57029 57089 57090 57208 57209 57205 57206 57691 57692 57806 57809 58261 58262 58318 58319 59076 59077 59130 59134 59427 59...
result:
ok Correct.
Test #32:
score: 0
Accepted
time: 12ms
memory: 7324kb
input:
100000 2 1 Duan 3 1 - 4 1 - 5 1 - 6 1 - 7 1 - 8 1 - 9 1 - 10 1 - 11 1 - 12 1 Tong 13 1 - 14 1 - 15 1 - 16 1 Tong 17 1 - 18 1 - 19 1 - 20 1 - 21 1 - 22 1 Tong 23 1 - 24 1 - 25 1 - 26 1 - 27 1 - 28 1 - 29 1 - 30 1 - 31 1 - 32 1 - 33 1 - 34 1 - 35 1 - 36 1 - 37 1 - 38 1 Tong 39 1 - 40 1 - 41 1 - 42 1 -...
output:
YES 92627 90226 98157 80552 99736 96463 94233 92271 89806 89512 86996 86460 86134 85511 67953 66335 71357 81710 80845 79593 77025 74512 73891 73888 72862 81856 69427 65770 64372 60624 56615 55714 48609 88314 97391 95440 93512 92584 92085 91747 89757 89327 99860 87691 85698 85374 85318 83893 82419 82...
result:
ok Correct.
Test #33:
score: 0
Accepted
time: 23ms
memory: 7496kb
input:
93284 2 1 - 3 1 Duan 4 2 - 5 4 - 6 2 - 7 4 Duan 8 1 - 9 4 - 10 4 Duan 11 6 - 12 7 - 13 6 - 14 1 Duan 15 4 - 16 9 - 17 12 - 18 15 - 19 6 Duan 20 1 - 21 15 - 22 2 - 23 5 Duan 24 7 - 25 22 - 26 13 - 27 12 - 28 6 - 29 27 Duan 30 7 Duan 31 9 - 32 14 - 33 3 - 34 21 - 35 18 - 36 35 - 37 7 - 38 17 Duan 39 2...
output:
YES 20816 74513 66130 81879 35338 89777 73761 62475 37702 71335 23517 33453 15222 56223 91225 86688 7805 29499 86109 58463 24560 41026 5910 47941 15686 44357 20522 70706 9149 22815 66681 46379 71082 81135 24083 47858 46291 85674 75184 79873 87023 73465 41087 33095 56514 9719 3487 53207 58715 82993 4...
result:
ok Correct.
Test #34:
score: 0
Accepted
time: 29ms
memory: 7496kb
input:
92284 2 1 Duan 3 2 - 4 3 Duan 5 2 Duan 6 3 - 7 4 Duan 8 6 Duan 9 4 Duan 10 6 Duan 11 4 Duan 12 8 Chang 13 1 Duan 14 5 Duan 15 5 - 16 15 Duan 17 15 Duan 18 13 Chang 19 12 Duan 20 4 - 21 1 Duan 22 17 Duan 23 2 Duan 24 14 Duan 25 17 Duan 26 22 Duan 27 4 - 28 26 Duan 29 9 Duan 30 15 Duan 31 3 Duan 32 7 ...
output:
YES 59373 72399 59795 64277 62511 76031 48883 62495 39444 59778 16425 86492 49780 13682 46706 65245 46022 57764 12085 12089 12688 91021 66749 41203 17794 40403 62095 90300 58704 62751 40542 35611 22903 19440 71273 77274 27633 72403 27548 47603 44368 44456 41743 16807 12412 24344 41680 61518 61610 52...
result:
ok Correct.
Test #35:
score: 0
Accepted
time: 35ms
memory: 7476kb
input:
93444 2 1 - 3 1 Duan 4 1 Duan 5 2 - 6 4 - 7 3 - 8 6 Duan 9 6 Duan 10 9 - 11 2 - 12 1 - 13 11 - 14 5 - 15 14 Duan 16 11 - 17 16 - 18 4 - 19 7 Duan 20 15 - 21 17 - 22 21 - 23 20 - 24 23 Duan 25 7 - 26 14 Duan 27 18 - 28 13 Duan 29 2 Duan 30 19 Duan 31 5 - 32 7 Duan 33 23 Duan 34 17 Duan 35 2 Duan 36 2...
output:
YES 18291 36095 58464 42330 59400 65585 1955 28016 40901 74817 89642 53918 63353 4623 82334 84984 57215 61350 54608 68628 6183 89498 50593 51738 36029 59238 62682 78448 8962 76817 77371 53894 72379 36051 32196 25512 15907 61507 17172 57517 14874 24983 79759 45334 4252 7489 61241 58719 47115 40373 29...
result:
ok Correct.
Test #36:
score: 0
Accepted
time: 43ms
memory: 7632kb
input:
98244 2 1 Duan 3 1 Duan 4 3 Duan 5 4 Duan 6 4 Duan 7 4 Duan 8 5 Duan 9 8 Duan 10 5 Duan 11 9 Duan 12 3 Duan 13 11 Tong 14 5 Duan 15 5 Duan 16 12 Duan 17 2 Duan 18 3 Duan 19 4 Duan 20 2 Duan 21 6 Duan 22 21 Duan 23 1 - 24 15 - 25 20 Duan 26 8 Duan 27 13 Duan 28 12 Duan 29 22 Duan 30 24 Duan 31 21 Dua...
output:
YES 31567 39340 13251 95866 63302 95270 54023 92175 48934 93485 24639 59312 21809 26380 39929 59491 50304 93197 37132 74962 50798 32873 3734 89682 68142 10918 61493 77790 2062 13569 89860 44405 3203 61508 52369 69831 43739 49035 28930 38807 66372 75766 86527 39400 3875 26746 27472 15465 1690 26723 7...
result:
ok Correct.
Test #37:
score: 0
Accepted
time: 6ms
memory: 4768kb
input:
25284 2 1 Duan 3 2 - 4 3 - 5 3 Duan 6 2 Duan 7 3 Duan 8 1 Duan 9 5 - 10 4 - 11 5 Duan 12 4 Duan 13 1 Duan 14 4 - 15 10 Duan 16 8 - 17 13 - 18 15 - 19 12 - 20 16 Duan 21 6 Duan 22 2 Duan 23 19 - 24 12 - 25 2 - 26 19 Duan 27 5 - 28 4 - 29 9 - 30 12 Duan 31 7 Duan 32 31 - 33 21 - 34 24 Duan 35 28 Duan ...
output:
YES 21135 14626 13835 14096 4428 23638 21260 14395 8988 14359 18822 12572 1866 20771 15210 24821 7235 23534 1084 16843 18384 22081 9125 23584 7918 17968 24718 16796 8913 23519 3762 23223 1868 17039 7940 15456 2957 6852 14498 16581 9470 19923 1916 9699 17156 18582 1797 6193 13962 8613 18684 3543 737 ...
result:
ok Correct.
Test #38:
score: 0
Accepted
time: 44ms
memory: 7444kb
input:
93246 2 1 Duan 3 2 Duan 4 3 Duan 5 1 - 6 4 Tong 7 4 Duan 8 4 Duan 9 8 - 10 6 Duan 11 2 Duan 12 1 Duan 13 11 Duan 14 8 Duan 15 1 Duan 16 8 Duan 17 10 Duan 18 3 Duan 19 1 Duan 20 18 Duan 21 10 Duan 22 14 Duan 23 11 Duan 24 19 Duan 25 21 Duan 26 17 Duan 27 24 Duan 28 24 Duan 29 17 Tong 30 23 Duan 31 17...
output:
YES 81889 89030 44827 92357 18804 92091 71114 88411 19189 41235 26335 88624 92987 34183 13889 37071 5382 7117 9021 63386 26290 70522 44641 74182 36015 63647 90356 91664 48141 62270 32796 68439 29179 71774 76068 92998 27623 62275 19705 86091 11009 89771 4652 8510 3815 64403 40253 9990 1699 62617 4358...
result:
ok Correct.
Test #39:
score: 0
Accepted
time: 31ms
memory: 7696kb
input:
99837 2 1 - 3 1 - 4 3 Duan 5 2 Duan 6 5 Duan 7 3 Duan 8 5 - 9 6 Duan 10 4 - 11 4 - 12 6 Duan 13 8 - 14 7 - 15 10 Duan 16 11 Duan 17 8 Duan 18 6 - 19 13 Duan 20 16 Duan 21 20 - 22 19 Chang 23 4 Duan 24 13 Duan 25 21 - 26 17 Duan 27 7 Duan 28 8 - 29 3 - 30 18 - 31 21 Duan 32 27 Duan 33 21 Duan 34 17 -...
output:
YES 10410 92676 39274 64479 78859 94138 21274 30205 8785 30056 83693 37886 73635 88306 11691 28522 30919 57401 38138 64681 93491 9496 51332 63118 28452 66215 51297 92328 23727 94426 74562 77931 42129 34253 23327 48303 79346 51081 10299 74255 69759 78121 16245 96354 90972 84360 95214 62165 10872 1788...
result:
ok Correct.
Test #40:
score: 0
Accepted
time: 33ms
memory: 7460kb
input:
91248 2 1 Duan 3 1 Duan 4 1 Duan 5 2 Duan 6 3 Duan 7 3 Chang 8 2 Duan 9 1 Duan 10 7 Duan 11 10 Duan 12 4 Duan 13 2 Duan 14 11 Duan 15 6 Duan 16 8 Duan 17 7 Duan 18 2 Duan 19 15 Duan 20 4 Duan 21 7 Duan 22 6 Duan 23 6 Duan 24 20 Duan 25 13 Duan 26 22 Duan 27 5 Duan 28 19 Duan 29 14 Duan 30 12 - 31 8 ...
output:
YES 84342 88470 76377 84352 45791 63352 50883 88200 18535 44680 47797 31347 12022 50617 6719 66762 5130 67174 77457 89212 59725 66802 46630 69332 56151 90420 44293 80259 50828 74573 68733 46329 53256 19496 15888 32591 6154 48424 27747 25680 25066 81109 5287 89180 54094 10884 31562 32892 2581 2675 40...
result:
ok Correct.
Test #41:
score: 0
Accepted
time: 34ms
memory: 7500kb
input:
93538 2 1 - 3 2 - 4 2 - 5 3 Duan 6 4 - 7 4 - 8 2 - 9 1 - 10 7 - 11 4 Duan 12 8 - 13 9 - 14 1 Duan 15 7 Duan 16 3 - 17 5 - 18 14 Duan 19 5 - 20 7 - 21 15 Duan 22 9 - 23 8 - 24 16 Duan 25 5 Duan 26 6 Duan 27 10 - 28 7 - 29 21 Duan 30 1 - 31 18 - 32 13 - 33 6 - 34 28 - 35 16 Duan 36 32 Duan 37 22 - 38 ...
output:
YES 78212 71885 6100 37718 40991 49527 80389 92012 68659 81271 43095 62371 41814 79642 73661 57857 24540 48483 16398 52557 56423 41232 3709 54473 78939 48165 74318 74690 61871 68804 24101 24274 64890 70628 41770 84790 40451 53698 42520 39635 25034 91102 39256 90535 58422 77572 11894 91112 16393 7240...
result:
ok Correct.
Test #42:
score: 0
Accepted
time: 39ms
memory: 9320kb
input:
92384 2 1 Duan 3 2 - 4 3 Duan 5 3 Duan 6 3 - 7 2 Duan 8 1 - 9 7 Duan 10 5 Chang 11 4 - 12 3 Duan 13 7 - 14 9 Duan 15 14 Chang 16 3 Duan 17 6 Duan 18 10 Duan 19 17 Duan 20 10 - 21 2 Duan 22 10 - 23 5 Duan 24 18 - 25 11 - 26 13 Duan 27 12 Duan 28 1 - 29 18 Duan 30 28 Duan 31 28 - 32 16 - 33 27 Duan 34...
output:
YES 52483 65469 39644 66814 11062 44726 9868 79880 37247 59560 77144 88171 24217 76272 85792 61782 57105 80279 37735 68289 31363 58829 26773 44877 18959 91292 43740 70419 7777 15239 9911 90532 90866 31792 63278 48350 12673 57214 33091 78633 72507 87915 37461 71152 52979 55042 64528 72909 41920 44823...
result:
ok Correct.
Test #43:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
1
output:
YES
result:
ok Correct.