QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#177207 | #6396. Puzzle: Kusabi | mendicillin2# | AC ✓ | 39ms | 21420kb | C++17 | 4.4kb | 2023-09-12 17:48:05 | 2023-09-12 17:48:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
template <class T> int sz(T&& a) { return int(size(forward<T>(a))); }
template <class T> using vc = vector<T>;
template <class T> using vvc = vc<vc<T>>;
using ll = int64_t;
using vi = vc<int>;
template <class F>
struct ycr {
F f;
template <class T>
explicit ycr(T&& f_) : f(forward<T>(f_)) {}
template <class... Args>
decltype(auto) operator()(Args&&... args) {
return f(ref(*this), forward<Args>(args)...);
}
};
template <class F>
decltype(auto) yc(F&& f) {
return ycr<decay_t<F>>(forward<F>(f));
}
const int N=1e5+5;
int n;
int p[N],fa[N],op[N];
struct node{
int to,last;
}tree[N*2];
int ss=1,head[N];
inline void add(int from,int to)
{
tree[++ss].to=to;
tree[ss].last=head[from];
head[from]=ss;
}
int re[N];
int len1=0, len2=0, len3=0;
int re1[N],re2[N],re3[N],deep[N];
bool pre[N],suf[N];
int ans[N];
inline bool cmp(int x,int y)
{
return deep[x]<deep[y];
}
void match(int i, int j) {
ans[i] = j;
ans[j] = i;
}
void NO() {
cout << "NO" << endl;
exit(0);
}
inline void dfs(int from,int x)
{
deep[x]=deep[from]+1;
for(int i=head[x];i;i=tree[i].last)
{
int k=tree[i].to;
dfs(x,k);
}
//cout<<x<<" "<<"yes"<<endl;
len1=len2=len3=0;
for(int i=head[x];i;i=tree[i].last)
{
int k=tree[i].to;
if(re[k]==0) continue;
else if(op[re[k]]==1) re1[++len1]=re[k];
else if(op[re[k]]==2) re2[++len2]=re[k];
else re3[++len3]=re[k];
}
if(op[x]==1) re1[++len1]=x;
else if(op[x]==2) re2[++len2]=x;
else if(op[x]==3) re3[++len3]=x;
sort(re1+1,re1+len1+1,cmp);
sort(re2+1,re2+len2+1,cmp);
sort(re3+1,re3+len3+1,cmp);
vector<int> rem;
//if(op[x]==0)
//{
// tong
{
vector<int> bads;
for (int st = 1; st <= len2; ) {
int en = st+1;
while (en <= len2 && deep[re2[st]] == deep[re2[en]]) en++;
if ((en - st) % 2 == 1) {
bads.push_back(re2[st]);
for (int i = st+1; i+1 < en; i += 2) {
ans[re2[i]] = re2[i+1];
ans[re2[i+1]] = re2[i];
}
} else {
for (int i = st; i+1 < en; i += 2) {
ans[re2[i]] = re2[i+1];
ans[re2[i+1]] = re2[i];
}
}
st = en;
}
if (bads.size() > 1) {
cout<<"NO"<<endl;
exit(0);
}
if (bads.size() == 1) {
rem.push_back(bads[0]);
}
}
// chang duan
{
if(abs(len1-len3)>1)
{
cout<<"NO"<<endl;
exit(0);
}
if(len1==len3)
{
for(int i=1;i<=len1;i++)
if(deep[re1[i]]>=deep[re3[i]])
{
cout<<"NO"<<endl;
exit(0);
}
else
{
ans[re1[i]]=re3[i];
ans[re3[i]]=re1[i];
}
}
else if(len1==len3+1)
{
vector<int> z;
int j = 1;
for (int i = 1; i <= len3; i++) {
while (j <= len1 && deep[re1[j]] < deep[re3[i]]) {
z.push_back(re1[j]);
j++;
}
if (z.empty()) {
NO();
}
match(re3[i], z.back());
z.pop_back();
}
while (j <= len1) z.push_back(re1[j++]);
assert(z.size() == 1);
rem.push_back(z[0]);
}
else
{
assert(len1 == len3-1);
vector<int> z;
int j = len3;
for (int i = len1; i >= 1; i--) {
while (j >= 1 && deep[re1[i]] < deep[re3[j]]) {
z.push_back(re3[j]);
j--;
}
if (z.empty()) {
NO();
}
match(re1[i], z.back());
z.pop_back();
}
while (j >= 1) z.push_back(re3[j--]);
assert(z.size() == 1);
rem.push_back(z[0]);
}
}
if (rem.size() > 1) {
cout << "NO" << endl;
exit(0);
}
if (rem.size() == 1) {
re[x] = rem[0];
} else {
re[x] = 0;
}
//cerr << "x=" << x << ", re=" << re[x] << endl;
//}
// else if(op[x]==1)
// {
// if(len1 || len2 || len3>1)
// {
// cout<<"NO"<<endl;
// exit(0);
// }
// if(len3==0) re[x]=x;
// else ans[x]=re3[1], ans[re3[1]]=x;
// }
// else if(op[x]==2)
// {
// if(len1 || len3 || len2)
// {
// cout<<"NO"<<endl;
// exit(0);
// }
// re[x]=x;
// }
// else if(op[x]==3)
// {
// if(len1 || len3 || len2)
// {
// cout<<"NO"<<endl;
// exit(0);
// }
// re[x]=x;
// }
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
cout << fixed << setprecision(20);
cin>>n; int id;
string s;
for(int i=2;i<=n;i++)
{
cin>>id>>fa[i]>>s;
add(fa[i],i);
if(s=="Duan") op[i]=1;
else if(s=="Tong") op[i]=2;
else if(s=="Chang") op[i]=3;
}
dfs(0,1);
if(re[1])
{
cout<<"NO"<<endl;
exit(0);
}
cout<<"YES"<<endl;
for(int i=1;i<=n;i++)
{
if(i>ans[i]) continue;
cout<<i<<" "<<ans[i]<<endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5932kb
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: 0ms
memory: 3928kb
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 2 6 3 10 5 7 8 9
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
2 2 1 Tong
output:
NO
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 31ms
memory: 7800kb
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 2 38925 3 17507 5 4737 7 86015 10 75059 12 62351 13 43170 14 879 16 92645 17 78130 19 92154 20 693 21 3946 22 26603 24 18570 25 3211 29 86603 32 92026 34 73620 35 2350 36 7180 38 9297 39 181 40 99610 41 97678 43 2826 47 70085 48 57024 50 58972 51 55750 55 2855 56 1008 57 27675 58 89545 59 5527 6...
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 20ms
memory: 7668kb
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 24 768 45 1824 81 340 85 128 93 8661 112 685 120 126 138 256 151 874 161 2444 162 226 168 823 206 1489 227 19121 240 269 295 5055 333 1088 334 1878 345 519 351 1721 352 16306 382 614 400 6962 402 1103 407 931 411 61041 420 431 426 2578 435 5819 459 657 477 25610 548 899 562 2378 563 656 594 1759...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 39ms
memory: 6868kb
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 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 23 19 20 21 33 22 34 25 26 27 28 29 41 30 45 31 37 32 39 35 36 38 43 40 42 46 48 49 63 50 66 52 53 54 60 55 65 56 57 58 61 59 73 64 68 67 69 70 78 71 79 74 91 75 90 76 82 77 87 80 93 81 126 83 85 84 86 89 94 92 104 95 105 96 112 97 100 98 101 99 114 102 190...
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 23ms
memory: 7596kb
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 10 12 13 14 17 18 26 30 28 32 38 47 51 55 59 70 74 82 80 116 81 85 103 117 105 107 126 131 130 134 133 157 137 141 138 144 139 145 147 156 149 165 151 160 163 181 168 172 169 199 173 189 174 185 179 188 197 216 207 218 211 231 223 255 224 230 233 250 244 247 253 265 260 262 273 275 278 302 279 2...
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 25ms
memory: 7900kb
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 6 10 12 13 15 16 19 23 25 27 31 36 39 44 46 47 52 53 59 62 65 66 68 69 71 74 79 81 82 87 83 92 93 94 98 100 102 105 108 110 112 117 118 120 122 130 132 133 134 142 144 148 155 161 165 168 169 170 171 173 175 178 183 187 194 199 202 207 203 205 212 214 215 217 221 225 223 224 226 232 227 237 242 ...
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 29ms
memory: 8016kb
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 6 9 11 13 14 16 18 20 21 22 24 25 26 29 30 31 33 34 35 38 39 40 42 44 47 49 51 52 53 54 55 56 57 58 59 60 61 62 63 64 66 70 74 77 78 80 81 83 84 86 87 92 93 94 96 98 100 102 107 108 109 110 114 115 116 117 118 121 124 125 126 130 131 134 137 138 144 146 147 152 149 150 155 156 158 162 164 165 16...
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 10ms
memory: 8680kb
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 46 187 379 560 617 664 1104 1599 1692 1891 2060 2120 2231 2560 3050 3072 3156 3161 3406 3700 3934 3939 4116 4338 4326 4581 4758 4774 4915 4986 5196 5281 5384 5513 5677 6435 6536 6606 6570 6738 7012 7037 7170 7289 7658 7686 7894 7922 8110 8465 8862 9157 9716 9769 9829 10261 11025 11281 11644 1257...
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 19ms
memory: 7520kb
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 7 71892 25 14925 46 82288 51 80221 55 97703 58 26407 59 96785 60 91401 65 50980 66 51167 74 97357 77 20592 78 49250 85 58877 90 75655 103 62887 123 13588 131 17852 134 64231 140 3539 150 65239 152 56022 161 13504 163 71210 168 95779 183 7850 196 26470 199 41715 204 73225 205 55212 209 6399 216 5...
result:
ok Correct.
Test #12:
score: 0
Accepted
time: 17ms
memory: 7376kb
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 36 22130 63 57657 76 96349 77 14634 113 12899 132 97642 140 40657 142 31650 175 61760 177 19578 192 14582 196 77379 228 95276 233 54443 236 9551 261 53230 264 41989 270 53197 281 32255 286 59650 317 41102 331 11417 336 68836 350 2306 358 45357 361 31755 373 22317 378 11525 403 49539 404 49344 40...
result:
ok Correct.
Test #13:
score: 0
Accepted
time: 39ms
memory: 6444kb
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 2 40264 3 63650 4 54405 5 23970 6 18192 8 37844 9 24245 11 1036 13 20492 14 5302 15 68062 16 85657 17 63778 19 20720 20 33757 22 18578 23 22927 24 63968 25 32756 26 57591 27 56804 28 12593 29 98530 30 76023 31 39340 33 85566 34 11351 35 61297 36 54473 38 26457 39 9125 40 18427 42 9247 43 65079 4...
result:
ok Correct.
Test #14:
score: 0
Accepted
time: 25ms
memory: 7412kb
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 13 1769 29 6875 32 10200 35 5804 45 61077 53 21405 55 18639 63 70603 72 85141 74 24892 80 9647 81 11975 91 5336 103 29231 104 11497 106 80268 110 85575 111 83330 117 18542 128 25906 135 96765 137 66578 140 45066 144 12955 155 34440 163 28516 164 26563 185 23613 217 18229 221 97368 227 24628 237 ...
result:
ok Correct.
Test #15:
score: 0
Accepted
time: 7ms
memory: 7264kb
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 2 2074 5 2973 33 76201 64 14534 65 97300 75 31363 76 23362 91 41770 92 99053 94 57432 113 34033 119 20107 126 61447 129 81112 141 96074 144 80731 149 42566 151 77178 157 74123 165 81647 168 75009 169 79109 177 89542 203 54362 204 80320 209 35084 212 90448 236 83633 237 92276 261 48550 263 37309 ...
result:
ok Correct.
Test #16:
score: 0
Accepted
time: 28ms
memory: 7268kb
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 2 86064 3 4495 5 70295 7 36969 8 27149 9 18842 10 10249 14 84324 15 52104 16 90816 18 42337 19 53437 20 40829 23 55408 24 27469 25 64924 28 10297 29 74218 31 99881 32 25200 34 68228 36 81276 37 64173 38 31424 40 83372 45 71777 48 98549 50 97667 59 71332 60 28667 64 23804 68 52275 70 97304 74 736...
result:
ok Correct.
Test #17:
score: 0
Accepted
time: 20ms
memory: 6704kb
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: 9ms
memory: 7552kb
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: 6752kb
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: 17ms
memory: 6760kb
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: 17ms
memory: 6884kb
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: 15ms
memory: 6992kb
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: 14ms
memory: 7168kb
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: 15ms
memory: 6648kb
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: 12ms
memory: 6952kb
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: 18ms
memory: 7664kb
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: 7240kb
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: 6392kb
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: 16ms
memory: 7160kb
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: 21ms
memory: 6468kb
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: 20ms
memory: 21420kb
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 2 4 6 7 10 11 12 13 14 15 19 22 23 24 26 27 28 30 31 33 34 35 36 37 38 39 41 42 43 44 48 49 50 51 53 54 55 56 57 59 60 61 63 64 67 68 69 70 71 73 74 75 76 77 78 79 80 81 83 84 85 87 88 89 90 91 93 94 95 96 98 100 101 105 107 109 110 111 112 114 115 117 118 120 121 122 123 124 125 126 127 128 131...
result:
ok Correct.
Test #32:
score: 0
Accepted
time: 15ms
memory: 7412kb
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 2 71956 12 285 16 22 38 43 45 50 58 61 62 75 83 221 96 208 102 103 107 120 122 124 127 164 172 195 201 203 233 1165 238 242 251 253 256 257 261 265 270 271 278 728 286 287 300 301 303 317 322 328 330 345 351 378 380 642 393 394 397 403 405 414 415 422 425 442 444 448 456 2066 460 551 461 463 484...
result:
ok Correct.
Test #33:
score: 0
Accepted
time: 23ms
memory: 6496kb
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 3 70896 7 26329 10 23726 14 6197 19 70006 23 84022 29 90882 30 26041 38 80827 40 46048 43 9877 44 6175 45 23610 54 17401 59 27190 62 41373 68 75193 70 12325 71 62586 72 916 80 29504 94 33591 96 68799 101 211 105 19300 106 42309 107 17227 110 18165 119 46550 124 4886 126 16194 134 27497 141 60028...
result:
ok Correct.
Test #34:
score: 0
Accepted
time: 24ms
memory: 7948kb
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 2 13373 4 2166 5 22918 7 28800 8 116 9 84 10 53721 11 29607 12 179 13 18 14 394 16 9314 17 3387 19 46270 21 598 22 42602 23 14922 24 81252 25 14864 26 53925 28 59243 29 87358 30 8973 31 3444 32 713 33 65424 34 43497 35 52669 36 16042 38 83447 39 59069 40 30268 41 17440 42 62010 43 11802 44 4549 ...
result:
ok Correct.
Test #35:
score: 0
Accepted
time: 20ms
memory: 7504kb
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 3 61906 4 11358 8 18653 9 45894 15 10640 19 45386 24 3928 26 88017 28 67164 29 81097 30 32417 32 59824 33 12119 34 26014 35 386 36 22796 38 2412 40 14500 45 23369 46 6286 47 49988 48 91033 49 69868 50 1172 51 79527 54 15345 55 29484 57 86147 60 707 61 54048 64 3708 66 2972 70 88396 73 74715 74 1...
result:
ok Correct.
Test #36:
score: 0
Accepted
time: 19ms
memory: 7640kb
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 2 23674 3 38963 4 28466 5 1500 6 20540 7 58209 8 45762 9 233 10 46231 11 32706 12 6282 13 90829 14 8113 15 22260 16 20481 17 82626 18 92802 19 92 20 3433 21 1580 22 23073 25 19064 26 74490 27 703 28 29019 29 8493 30 93636 31 3530 32 1286 33 1233 34 42264 35 5124 36 72098 37 8607 38 27365 39 9055...
result:
ok Correct.
Test #37:
score: 0
Accepted
time: 7ms
memory: 4488kb
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 2 4395 5 532 6 1283 7 18302 8 39 11 162 12 1149 13 9986 15 50 20 13263 21 131 22 621 26 11504 30 15967 31 17319 34 13760 35 12913 37 7513 41 17662 43 22457 45 4058 46 6525 49 4443 52 7888 54 1413 56 7377 57 23609 58 17450 59 2514 60 21582 62 20377 63 447 64 25093 65 3658 69 20763 70 9678 71 1939...
result:
ok Correct.
Test #38:
score: 0
Accepted
time: 32ms
memory: 7772kb
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 2 64219 3 56002 4 431 6 65969 7 117 8 90195 10 1093 11 66838 12 2577 13 11408 14 22450 15 38 16 6050 17 7545 18 11710 19 5360 20 6476 21 6997 22 3416 23 77446 24 61543 25 64116 26 712 27 21182 28 3232 29 923 30 4572 31 39307 32 155 34 86 35 46 36 5533 39 32236 40 29816 41 76232 42 42567 43 79108...
result:
ok Correct.
Test #39:
score: 0
Accepted
time: 31ms
memory: 6744kb
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 4 64769 5 55324 6 56 7 37503 9 79601 12 14026 15 29349 16 85991 17 7539 19 22 20 54025 23 99801 24 93428 26 7420 27 2824 31 14270 32 16505 33 85314 36 14345 38 90170 41 79463 42 4047 44 68317 45 64605 46 20274 48 97387 49 16667 51 22281 52 45921 53 31927 54 69 62 96975 63 185 65 31626 70 33987 7...
result:
ok Correct.
Test #40:
score: 0
Accepted
time: 23ms
memory: 7592kb
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 2 14844 3 7 4 1283 5 13646 6 5425 8 2386 9 89 10 32407 11 86394 12 6759 13 28482 14 14361 15 1746 16 26015 17 18735 18 432 19 19220 20 58836 21 40803 22 13131 23 681 24 141 25 75138 26 9374 27 18469 28 95 29 1136 31 55967 32 35799 33 18565 34 59705 35 66866 36 1436 37 5598 38 31774 39 67427 40 3...
result:
ok Correct.
Test #41:
score: 0
Accepted
time: 19ms
memory: 6564kb
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 5 29409 11 577 14 61785 15 75817 18 1069 21 19923 24 90631 25 27246 26 39111 29 9412 35 54512 36 48776 38 2082 40 55885 42 56411 44 49160 52 74647 53 5491 55 7505 56 87453 58 38579 60 52897 61 87626 64 28484 65 29582 66 5478 69 76855 71 30166 72 16754 74 74755 75 17466 78 65109 82 30377 83 83057...
result:
ok Correct.
Test #42:
score: 0
Accepted
time: 29ms
memory: 6588kb
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 2 64125 4 9852 5 10 7 552 9 77941 12 1585 14 91324 15 294 16 8406 17 58124 18 18021 19 14129 21 26651 23 66074 26 792 27 65458 29 5090 30 7499 33 5135 34 67281 35 5775 36 1345 38 59681 39 60642 40 130 41 40542 42 78605 46 75388 47 914 49 76553 51 63 52 42024 53 645 54 2838 55 24554 57 89849 58 1...
result:
ok Correct.
Test #43:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
1
output:
YES
result:
ok Correct.