QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#230862 | #6396. Puzzle: Kusabi | kiwiHM | AC ✓ | 40ms | 37160kb | C++14 | 4.1kb | 2023-10-28 21:20:44 | 2023-10-28 21:20:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int a[maxn];
int dep[maxn], tong[maxn];
vector<pair<int, int> > ans;
vector<int> tree[maxn];
inline int dfsTong(int u, int d){
dep[u] = d;
vector<int> vec;
for(auto v: tree[u]){
int res = dfsTong(v, d + 1);
if(~res){
tong[v] = true;
vec.push_back(res);
}
}
sort(vec.begin(), vec.end(), [&](const int &i, const int &j){ return dep[i] < dep[j]; });
int res = -1;
for(int i = 0; i < vec.size(); ){
if(i + 1 == vec.size()){
if(~res){ puts("NO"); exit(0); }
res = vec[i], ++i;
}
else{
if(dep[vec[i + 1]] == dep[vec[i]]) ans.push_back(make_pair(vec[i], vec[i + 1])), i += 2;
else{
if(~res){ puts("NO"); exit(0); }
res = vec[i], ++i;
}
}
}
if(a[u] == 1){
if(~res){ puts("NO"); exit(0); }
res = u;
}
return res;
}
inline vector<int> erase(const vector<int> &vec, int p){
vector<int> ret;
assert(p >= 0 && p < vec.size());
for(int i = 0; i < vec.size(); ++i) if(i != p) ret.push_back(vec[i]);
return ret;
}
inline bool check(vector<int> &A, vector<int> &B){
assert(A.size() == B.size());
for(int i = 0; i < A.size(); ++i) if(dep[A[i]] >= dep[B[i]]) return false;
return true;
}
inline pair<int, int> dfs(int u){
vector<int> vDuan, vChang;
for(auto v: tree[u]){
pair<int, int> res = dfs(v);
if(tong[v] && res.first != -1){ puts("NO"); exit(0); }
if(res.first == 0) vDuan.push_back(res.second);
if(res.first == 2) vChang.push_back(res.second);
}
if(a[u] == 0) vDuan.push_back(u);
if(a[u] == 2) vChang.push_back(u);
sort(vDuan.begin(), vDuan.end(), [&](const int &i, const int &j){ return dep[i] < dep[j]; });
sort(vChang.begin(), vChang.end(), [&](const int &i, const int &j){ return dep[i] < dep[j]; });
pair<int, int> ret = make_pair(-1, 0);
if(vDuan.size() == vChang.size()){
for(int i = 0; i < vDuan.size(); ++i){
if(dep[vDuan[i]] < dep[vChang[i]]){
ans.push_back(make_pair(vDuan[i], vChang[i]));
}
else{ puts("NO"); exit(0); }
}
return ret;
}
else if(vDuan.size() == vChang.size() + 1){
int lb = -1, rb = vDuan.size();
for(; lb + 1 < rb; ){
int md = (lb + rb) >> 1;
vector<int> vDuan_ = erase(vDuan, md);
if(check(vDuan_, vChang)) rb = md;
else lb = md;
}
if(rb == vDuan.size()){ puts("NO"); exit(0); }
ret = make_pair(0, vDuan[rb]);
vDuan = erase(vDuan, rb); assert(vDuan.size() == vChang.size());
for(int i = 0; i < vDuan.size(); ++i) ans.push_back(make_pair(vDuan[i], vChang[i]));
return ret;
}
else if(vChang.size() == vDuan.size() + 1){
int lb = -1, rb = vChang.size();
for(; lb + 1 < rb; ){
int md = (lb + rb) >> 1;
vector<int> vChang_ = erase(vChang, md);
if(check(vDuan, vChang_)) lb = md;
else rb = md;
}
if(lb == -1){ puts("NO"); exit(0); }
ret = make_pair(2, vChang[lb]);
vChang = erase(vChang, lb); assert(vDuan.size() == vChang.size());
for(int i = 0; i < vDuan.size(); ++i) ans.push_back(make_pair(vDuan[i], vChang[i]));
return ret;
}
else{ puts("NO"); exit(0); }
}
int main(){
scanf("%d", &n);
a[0] = -1;
for(int it = 1; it < n; ++it){
int i, p; scanf("%d%d", &i, &p);
char buf[15]; scanf("%s", buf);
--i, --p;
tree[p].push_back(i);
if(buf[0] == 'D') a[i] = 0;
else if(buf[0] == 'T') a[i] = 1;
else if(buf[0] == 'C') a[i] = 2;
else a[i] = -1;
}
if(~dfsTong(0, 0)){ puts("NO"); return 0; }
if(~dfs(0).first){ puts("NO"); return 0; }
puts("YES");
for(auto p: ans) printf("%d %d\n", p.first + 1, p.second + 1);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 7160kb
input:
8 2 1 - 3 1 - 4 2 Tong 5 2 Tong 6 3 Duan 7 3 - 8 7 Chang
output:
YES 4 5 6 8
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 1ms
memory: 6816kb
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 8 9 3 10 2 6 7 5
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 6700kb
input:
2 2 1 Tong
output:
NO
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 33ms
memory: 9056kb
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 46666 56115 6569 30148 33377 66951 8453 22475 62906 90542 24067 38490 32926 46831 29971 38013 44239 52707 4968 20252 38126 41107 25557 95124 18851 96822 45515 95318 13081 62455 3589 6955 32999 85894 20033 25554 62757 83733 60682 83311 10876 71111 45590 46746 32192 38043 21163 68991 14736 31677 4...
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 30ms
memory: 9548kb
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 91669 86909 66693 91216 88445 98194 26090 60566 58516 62213 53772 91675 31351 49597 71561 78719 9516 17993 59163 95817 51224 91662 58056 80003 57077 58160 70817 81298 80747 45650 63106 65739 53137 91558 59781 98386 47477 63482 6738 7202 33423 54257 10437 27020 55605 70788 64012 85809 66381 90867...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 40ms
memory: 9680kb
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 2399 2710 2179 2259 39438 43415 36938 38882 14457 15595 27193 28309 58521 66951 61422 74252 34106 34548 35345 37628 14741 15906 72744 73573 63627 77876 73356 78955 84359 90391 50580 52896 41945 48665 75373 76074 44678 47783 96320 99969 88051 92752 43769 52424 37612 37915 31579 42304 58498 60814 ...
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 40ms
memory: 9568kb
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 105 107 103 117 429 437 995 1021 1328 1329 2064 2101 2197 2216 4792 5211 3641 3704 5737 6063 6319 6509 9839 10210 9022 9750 14399 14929 71815 76566 83455 84389 75733 76028 93323 99645 43291 44379 26634 26667 40330 43401 34163 35496 33989 34139 30555 31415 29941 30463 45020 46555 80952 89452 7103...
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 31ms
memory: 9660kb
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 265 266 338 341 1159 1160 1460 1466 1473 1507 1497 1515 1601 1569 1019 1021 1081 1110 1292 1312 1239 1261 1281 1317 1444 1450 1910 1928 1849 1872 1943 1948 2103 2112 2615 2640 2648 2719 2609 2614 2623 2660 3443 3458 3275 3193 4530 4554 4020 4068 3773 3785 3733 3736 3967 4105 3323 3352 3529 3644 ...
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 30ms
memory: 10024kb
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 772 773 830 831 845 849 895 897 1057 1058 1054 1056 1323 1326 1304 1305 1530 1531 1643 1645 1636 1639 1942 1954 2068 2071 2124 2132 2104 2105 2100 2106 2079 2080 2371 2402 2385 2387 2405 2393 2399 2412 2394 2396 2364 2365 2353 2359 2282 2283 2507 2519 2488 2495 2670 2685 2663 2680 2660 2668 3149...
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 20ms
memory: 10528kb
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 46356 46361 85950 86202 35528 35551 4915 4986 6570 6738 13597 14195 22019 22308 31792 31800 38225 38186 43803 43898 41995 41864 42327 42725 43807 43871 43542 43953 47608 47755 46932 47521 44955 46885 48486 48399 49839 50116 49668 49912 53355 54823 54273 54714 53853 54239 52524 52947 55640 57456 ...
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 24ms
memory: 8812kb
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 34242 34406 14906 23870 28768 79207 50509 68052 36153 68751 18177 70173 50978 58218 65881 90916 44928 67031 28068 95211 43712 69374 32128 70765 30451 79850 74601 94590 13691 68964 73748 71564 20808 41618 51772 81363 5508 25431 44539 98097 98648 96217 4882 43435 40270 64252 4986 45349 63196 83117...
result:
ok Correct.
Test #12:
score: 0
Accepted
time: 23ms
memory: 8176kb
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 15102 66302 37177 40113 67735 67876 70745 98880 75547 84740 88398 71830 62593 85699 37672 71660 90862 91238 13573 72747 10218 81223 15063 87004 17731 33161 49326 65914 45470 93622 6248 26633 22131 38750 81298 59003 12493 46378 62767 99085 29771 34801 68801 93527 24315 84801 47973 64651 33448 683...
result:
ok Correct.
Test #13:
score: 0
Accepted
time: 27ms
memory: 8168kb
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 63894 95158 88697 88086 85544 75216 73765 72642 72241 69085 14063 61983 55203 54430 50491 41588 40110 38849 34955 27596 10786 18595 21493 24025 25178 30164 30800 40282 50699 52476 59910 76452 79238 86389 91441 96792 34098 46043 47433 49151 56601 57549 59254 65754 66989 87547 94062 96382 14791 21...
result:
ok Correct.
Test #14:
score: 0
Accepted
time: 19ms
memory: 8060kb
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 51260 62964 64799 73003 87232 98672 31245 38059 47626 58383 78385 82570 84269 91105 67893 90700 95599 97507 51711 96567 90521 97467 52378 20327 24851 31941 34768 35502 36133 37919 38081 41305 46820 47134 51834 18144 52602 53825 60150 63344 65516 68450 79862 84495 88745 90845 99206 18138 2969 328...
result:
ok Correct.
Test #15:
score: 0
Accepted
time: 13ms
memory: 8216kb
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 51853 97806 89831 81679 70717 62015 60751 59449 56321 54934 54125 53261 24271 49313 49018 46496 43803 39709 39458 38753 38738 38484 37384 32530 58304 99744 99690 97190 93135 88437 76662 73977 73029 71317 68370 61172 61007 58424 18859 57761 57280 55259 54712 46485 44356 43694 39921 34688 33247 30...
result:
ok Correct.
Test #16:
score: 0
Accepted
time: 16ms
memory: 7964kb
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 60220 72014 80211 95022 93125 94029 59250 85950 77242 89854 56243 61755 80147 86382 86818 91748 87876 89771 30379 31237 31218 31062 31048 30964 30860 30850 30689 30666 30642 30487 31450 30316 30298 30147 29890 29748 29745 29652 29648 29618 29555 29352 32432 33209 33191 32983 32973 32784 32771 32...
result:
ok Correct.
Test #17:
score: 0
Accepted
time: 23ms
memory: 8908kb
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: 23ms
memory: 8904kb
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: 17ms
memory: 9120kb
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: 26ms
memory: 9160kb
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: 33ms
memory: 9636kb
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: 22ms
memory: 9520kb
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: 22ms
memory: 9648kb
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: 21ms
memory: 9704kb
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: 26ms
memory: 8648kb
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: 23ms
memory: 8456kb
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: 19ms
memory: 8208kb
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: 19ms
memory: 7920kb
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: 18ms
memory: 7876kb
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: 18ms
memory: 8144kb
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: 22ms
memory: 37160kb
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 51264 51265 54865 54866 55425 55426 59825 59826 62733 62734 66328 66329 74865 74866 75873 75874 76634 76635 76821 76822 79783 79786 82317 82319 82735 82736 83174 83175 83753 83754 87037 87038 87072 87073 87392 87393 88429 88433 89484 89485 89835 89836 90258 90259 91024 91026 91050 91052 91582 91...
result:
ok Correct.
Test #32:
score: 0
Accepted
time: 12ms
memory: 7584kb
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 83748 84085 84052 84039 84036 84021 83989 83963 83894 83892 83875 83862 83794 83778 84100 83732 83710 83697 83679 83646 83641 83589 83567 83505 83453 83382 83381 83339 84510 84988 84986 84948 84886 84880 84874 84830 84731 84706 84680 84652 84592 84567 83330 84494 84484 84459 84457 84340 84313 84...
result:
ok Correct.
Test #33:
score: 0
Accepted
time: 28ms
memory: 8884kb
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 58881 75107 31602 50618 44633 28152 42717 56227 37862 29953 14996 30431 70724 77276 40380 83122 3573 16829 89143 76777 12571 60355 16266 28962 67234 88123 62455 63260 12019 42904 6883 87494 11314 19909 24918 66679 30467 64392 61163 61528 23841 17298 15552 55786 71115 48749 68329 88591 28478 7881...
result:
ok Correct.
Test #34:
score: 0
Accepted
time: 37ms
memory: 8892kb
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 32559 38566 46901 62069 15829 25303 27245 62442 75926 89999 10360 25714 3642 64304 84096 73541 49990 57524 45407 88447 72122 10940 38207 59085 18204 57122 39094 58168 12567 27582 8830 15043 76561 90409 42159 53744 20404 20870 8803 80981 64711 86239 43655 82211 33111 50596 40772 71079 59864 67274...
result:
ok Correct.
Test #35:
score: 0
Accepted
time: 31ms
memory: 8860kb
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 37302 55459 24623 33539 47285 47877 72113 34651 34185 41202 41133 46835 68083 86043 20223 89209 79601 83129 53264 61067 45418 74102 8345 39457 65330 84450 14082 84592 61752 72635 36825 37456 18841 21364 56236 74597 89996 90347 70894 75584 27525 43098 6158 16318 44962 66634 68938 87694 28947 5411...
result:
ok Correct.
Test #36:
score: 0
Accepted
time: 38ms
memory: 9244kb
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 15284 30277 58902 93724 84590 48839 80103 95194 37898 61416 18076 45708 55091 59246 16500 70761 29779 88661 60854 84559 24476 36164 80950 84194 85124 85527 32331 38297 12353 84009 39888 67842 44777 61495 62946 91893 35249 43559 83067 95663 15920 65231 59990 95885 32315 87786 46867 49435 55078 68...
result:
ok Correct.
Test #37:
score: 0
Accepted
time: 10ms
memory: 6988kb
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 14380 15197 1894 15884 9136 12672 14368 20232 15965 23256 9546 16303 1984 9610 22088 24427 22533 24383 10966 7450 14456 15635 11394 13503 12175 19508 19556 24484 9401 23114 9845 20058 19685 25118 13338 18562 24649 18504 19976 20630 12517 14993 16033 22556 23229 24293 4425 5835 7735 17950 1143 38...
result:
ok Correct.
Test #38:
score: 0
Accepted
time: 26ms
memory: 8876kb
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 3250 89556 60951 81387 50544 76768 408 6297 54843 70355 23612 29811 13562 23328 7896 17450 69391 76629 66595 71603 81312 92228 43042 67324 75155 10527 19977 58300 13977 22807 27534 61516 21648 91633 5630 65683 66695 68205 8278 43215 44658 58228 38328 89314 37406 74475 62928 88470 77708 88155 600...
result:
ok Correct.
Test #39:
score: 0
Accepted
time: 33ms
memory: 9048kb
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 37610 77117 70345 88367 55639 85507 51349 76696 58820 82138 59728 67104 357 72745 12578 39402 48016 84891 23953 40193 50283 62852 18024 81205 20064 45335 47141 54063 12379 13660 9703 86165 18916 41496 18609 60594 42700 55286 57439 78018 85904 57669 63808 76168 17197 22611 49161 52698 10965 24408...
result:
ok Correct.
Test #40:
score: 0
Accepted
time: 35ms
memory: 8860kb
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 22567 91137 49857 58707 50744 81884 35818 75987 26944 55452 53597 79088 35587 39251 8099 63624 3337 5181 36884 51301 12877 22677 56412 62620 48117 82680 50074 59646 48096 85371 7636 18857 71112 80447 72426 86854 36550 45506 71558 82774 49676 57949 67684 68906 4224 67847 4304 63393 62905 90853 25...
result:
ok Correct.
Test #41:
score: 0
Accepted
time: 35ms
memory: 9164kb
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 42715 63190 62809 83054 39273 86366 34873 68128 8792 16565 15988 17153 28608 25667 37206 79469 22537 29014 18956 27008 38337 79494 38890 26141 10027 53393 57733 74982 4619 39487 44906 63094 57295 64219 80373 85174 55856 73985 4595 5501 90470 93080 66615 89253 29718 43699 12318 87075 45920 47708 ...
result:
ok Correct.
Test #42:
score: 0
Accepted
time: 33ms
memory: 8880kb
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 50150 89303 34799 48940 63107 81589 69625 73581 31305 43086 24440 89244 65637 85551 14333 23298 33790 74280 55326 77312 13648 21983 4169 4556 59170 82916 38918 86042 25564 63697 14847 17460 64958 65866 58863 39060 31957 41682 8259 14027 45981 74102 24590 46215 63712 76329 7078 17957 89432 90747 ...
result:
ok Correct.
Test #43:
score: 0
Accepted
time: 2ms
memory: 7396kb
input:
1
output:
YES
result:
ok Correct.