QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#493208 | #9157. 树的定向 | jason_sun | 100 ✓ | 2100ms | 246104kb | C++14 | 6.0kb | 2024-07-26 21:38:45 | 2024-07-26 21:38:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=5e5+5;
struct BIT{
int tr[N];
int lowbit(int x){
return x&(-x);
}
void add(int x, int y){
while(x<N){
tr[x]+=y;
x+=lowbit(x);
}
}
int ask(int x){
int res=0;
while(x){
res+=tr[x];
x-=lowbit(x);
}
return res;
}
void add(int l, int r, int y){
add(l, y), add(r+1, -y);
}
}T1, T2;
//T1 ÏòÏÂ T2 ÏòÉÏ
vector<int> e[N];
int fa[N], dep[N], siz[N], bson[N], fi[N];
void dfs1(int x, int ff){
fa[x]=ff;
dep[x]=dep[ff]+1;
siz[x]=1;
for(auto y:e[x]){
if(y==ff) continue;
dfs1(y, x);
siz[x]+=siz[y];
if(siz[y]>siz[bson[x]]) bson[x]=y;
}
}
int dfn[N], rfn[N], top[N], dfncnt;
void dfs2(int x, int ff, int t){
dfn[x]=++dfncnt;
rfn[dfn[x]]=x;
top[x]=t;
if(bson[x]) dfs2(bson[x], x, t);
for(auto y:e[x]){
if(y==ff||y==bson[x]) continue;
dfs2(y, x, y);
}
}
int LCA(int x, int y){
while(top[x]!=top[y]){
if(dep[top[x]]<dep[top[y]]) swap(x, y);
x=fa[top[x]];
}
return dep[x]<dep[y]?x:y;
}
queue<pair<int,int>> q;
int pa[N]; set<pair<int,int>> son[N], lnk[N]; set<int> nd[N];
int px[N], py[N], qx[N], qy[N], ans[N];
int find_fa(int x){
return pa[x]==x?x:pa[x]=find_fa(pa[x]);
}
void change(int x, int y){
// printf("change %d %d\n", x, y);
ans[x]=y;
int pp=(dep[px[x]]>dep[py[x]]?px[x]:py[x]);
int k=((dep[px[x]]>dep[py[x]])^y);
if(k==1){
T2.add(dfn[pp], dfn[pp]+siz[pp]-1, 1);
}else{
T1.add(dfn[pp], dfn[pp]+siz[pp]-1, 1);
}
}
void print(int k){
int x=qx[k], y=qy[k];
printf("print %d %d %d\n", k, x, y);
int lca=LCA(x, y);
int tag=0;
while(x!=lca){
printf("x %d %d %d %d %d %d\n", x, fa[x], fi[x], ans[fi[x]], px[fi[x]], py[fi[x]]);
// assert((ans[fi[x]])^(dep[px[fi[x]]]>dep[py[fi[x]]]));
tag|=(ans[fi[x]])^(dep[px[fi[x]]]>dep[py[fi[x]]]);
x=fa[x];
}
while(y!=lca){
printf("y %d %d %d %d %d %d\n", y, fa[y], fi[y], ans[fi[y]], px[fi[y]], py[fi[y]]);
// assert((ans[fi[y]])^(dep[px[fi[y]]]<dep[py[fi[y]]]));
tag|=(ans[fi[y]])^(dep[px[fi[y]]]<dep[py[fi[y]]]);
y=fa[y];
}
assert(tag);
}
void check(int k){
int x=qx[k], y=qy[k];
int lca=LCA(x, y);
int ct=0;
while(x!=lca){
ct+=ans[fi[x]]==-1;
x=fa[x];
}
while(y!=lca){
ct+=ans[fi[y]]==-1;
y=fa[y];
}
assert(ct<=1);
}
void solve(int x, int y){
// if(y==290){
// printf("== solve %d %d\n", x, y);
// print(x);
// }
// check(x);
if(ans[y]!=-1) return;
int a=qx[x], b=qy[x];
int lca=LCA(a, b);
if((T1.ask(dfn[a])-T1.ask(dfn[lca]))||(T2.ask(dfn[b])-T2.ask(dfn[lca]))) return;
// printf("solve %d %d\n", x, y);
q.push({a, b});
int k1=dep[px[y]]>dep[py[y]];
int pp=k1?px[y]:py[y];
int k2=LCA(a, pp)==pp;
// printf("%d %d\n", k1, k2);
change(y, k1^k2^1);
}
void hb(int x, int y){
x=find_fa(x), y=find_fa(y);
if(x==y) return;
if(son[x].size()+lnk[x].size()<son[y].size()+lnk[y].size()) swap(x, y);
// printf("hb %d %d\n", x, y);
// puts("sonx: ");
// for(auto z:son[x]){
// printf("%d %d\n", z.first, z.second);
// }
// puts("lnkx: ");
// for(auto z:lnk[x]){
// printf("%d %d\n", z.first, z.second);
// }
// puts("sony: ");
// for(auto z:son[y]){
// printf("%d %d\n", z.first, z.second);
// }
// puts("lnky: ");
// for(auto z:lnk[y]){
// printf("%d %d\n", z.first, z.second);
// }
vector<pair<int,int>> p1, p2;
for(auto z:son[y]){
// printf("son %d %d\n", z.first, z.second);
son[z.first].erase({y, z.second});
if(z.first!=x){
son[z.first].insert({x, z.second});
p1.push_back(z);
}
auto it=lnk[x].lower_bound({z.first, 0});
while(it!=lnk[x].end()&&(*it).first==z.first){
solve((*it).second, z.second);
lnk[(*it).first].erase({x, (*it).second});
lnk[x].erase(it);
it=lnk[x].lower_bound({z.first, 0});
}
}
for(auto z:lnk[y]){
// printf("lnk %d %d\n", z.first, z.second);
lnk[z.first].erase({y, z.second});
auto it=son[x].lower_bound({z.first, 0});
if(it!=son[x].end()&&(*it).first==z.first){
while(it!=son[x].end()&&(*it).first==z.first){
solve(z.second, (*it).second);
it++;
}
}else if(z.first!=x){
lnk[z.first].insert({x, z.second});
p2.push_back(z);
}
}
// for(auto z:nd[y]){
//// printf("nd %d\n", z);
// auto it=son[x].lower_bound({z, 0});
// while(it!=son[x].end()&&(*it).first==z){
// son[x].erase(it);
// it=son[x].lower_bound({z, 0});
// }
// }
pa[y]=x;
for(auto z:p1){
son[x].insert(z);
}
for(auto z:p2){
lnk[x].insert(z);
}
son[y].clear(); lnk[y].clear(); nd[y].clear();
// puts("son: ");
// for(auto z:son[x]){
// printf("%d %d\n", z.first, z.second);
// }
// puts("lnk: ");
// for(auto z:lnk[x]){
// printf("%d %d\n", z.first, z.second);
// }
// for(auto z:son[x]){
// auto it=lnk[x].lower_bound({z.first, 0});
// if(!(it==lnk[x].end()||(*it).first!=z.first)){
// printf("%d %d\n", z.first, z.second);
// }
// assert(it==lnk[x].end()||(*it).first!=z.first);
// }
}
void flush(){
while(!q.empty()){
int x=q.front().first, y=q.front().second; q.pop();
hb(x, y);
}
}
int main(){
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
int c, n, m;
scanf("%d%d%d", &c, &n, &m);
for(int i=1; i<=n; ++i){
pa[i]=i;
nd[i].insert(i);
}
for(int i=1, x, y; i<n; ++i){
scanf("%d%d", &x, &y);
e[x].push_back(y);
e[y].push_back(x);
px[i]=x, py[i]=y;
}
dfs1(1, 0);
dfs2(1, 0, 1);
for(int i=1; i<n; ++i){
son[px[i]].insert({py[i], i});
son[py[i]].insert({px[i], i});
if(dep[px[i]]>dep[py[i]]){
fi[px[i]]=i;
}else{
fi[py[i]]=i;
}
}
memset(ans, -1, sizeof(ans));
for(int i=1, x, y; i<=m; ++i){
scanf("%d%d", &x, &y);
qx[i]=x, qy[i]=y;
if(x==fa[y]||y==fa[x]){
solve(i, dep[x]>dep[y]?fi[x]:fi[y]);
}else{
lnk[x].insert({y, i});
lnk[y].insert({x, i});
}
}
flush();
for(int i=1; i<n; ++i){
if(ans[i]==-1){
change(i, 0);
q.push({px[i],py[i]});
flush();
}
}
for(int i=1; i<n; ++i){
printf("%d", ans[i]);
}
putchar('\n');
return 0;
}
詳細信息
Pretests
Pretest #1:
score: 4
Accepted
time: 11ms
memory: 111080kb
input:
1 14 49 13 1 14 5 11 1 5 3 6 5 6 12 4 14 7 10 11 8 10 2 7 6 6 11 9 5 9 8 9 6 6 1 4 14 1 4 9 11 14 7 2 5 2 12 7 5 5 13 1 5 14 3 13 2 13 14 5 1 13 5 4 6 11 6 8 12 13 3 7 4 10 4 6 5 7 14 9 12 13 7 12 4 9 1 8 7 8 1 2 4 12 9 6 4 7 2 1 14 11 2 4 13 9 5 4 5 3 12 9 7 8 5 3 13 12 14 13 6 6 10 9 3 13 10
output:
0011111001001
result:
ok single line: '0011111001001'
Pretest #2:
score: 4
Accepted
time: 7ms
memory: 110232kb
input:
2 15 48 13 14 15 1 3 11 4 7 5 6 10 7 2 12 10 11 7 6 15 9 11 9 10 12 13 6 8 7 2 4 7 5 13 2 5 9 15 8 8 15 11 5 14 2 8 1 14 7 1 6 14 12 4 10 11 12 4 9 12 8 5 8 12 10 3 10 2 13 10 4 9 1 5 15 12 9 5 2 12 5 12 4 3 11 3 5 8 5 1 2 4 15 7 2 14 4 2 3 9 7 7 1 11 2 12 11 9 4 5 11 2 7 7 14 3 12 5 14 11 6 15 14 1...
output:
00100000000000
result:
ok single line: '00100000000000'
Pretest #3:
score: 4
Accepted
time: 4ms
memory: 110688kb
input:
3 13 47 9 12 2 11 1 6 8 4 3 8 8 2 13 9 10 2 2 7 10 1 8 5 4 9 13 11 4 13 5 3 11 5 9 8 4 8 11 7 7 1 11 9 10 1 3 13 11 6 4 1 5 2 12 6 8 6 9 11 5 6 9 7 8 7 9 10 4 12 11 10 11 4 10 12 12 13 12 5 7 10 10 5 1 11 12 3 1 12 1 6 1 8 4 11 13 7 7 3 3 2 7 13 10 7 3 7 1 3 4 7 11 1 6 12 3 5 8 10
output:
001001010111
result:
ok single line: '001001010111'
Pretest #4:
score: 4
Accepted
time: 15ms
memory: 111212kb
input:
4 300 300 48 298 40 60 194 26 121 298 136 298 276 124 245 171 115 298 44 26 201 245 125 64 298 74 216 44 105 162 201 112 298 220 209 166 216 105 164 14 105 246 284 112 213 246 40 195 246 218 16 284 219 16 298 256 298 295 169 218 191 123 298 229 140 276 218 95 219 123 298 257 21 58 290 298 258 298 4 ...
output:
01000110110011001000100011000000000100010101011001011011101011001000100100001110000110100100011101011111110001110110100010100111000100110101000101100101110001110110100000110000010101010010001100111110110001001011000101011001000101000101101101111111101101000110000001111111110110100100010100011111100
result:
ok single line: '010001101100110010001000110000...1111110110100100010100011111100'
Pretest #5:
score: 4
Accepted
time: 11ms
memory: 110288kb
input:
5 300 299 73 143 136 55 213 62 233 206 166 55 190 213 19 87 32 206 49 32 245 73 293 144 32 79 4 79 55 257 4 103 4 46 134 56 152 55 46 274 188 46 205 78 55 260 92 55 190 155 198 188 236 190 236 221 300 55 236 149 135 149 121 55 7 55 55 156 183 215 161 188 161 82 58 144 82 33 286 191 75 33 191 135 145...
output:
10100101000010001001010001000100011010011000100000000111010011101000000100110001010010100011110101010101010100110000000001101011010011001010111011000010011001011110101101011110001001100001011101110110101101000111100011010010100110100110010111010001101101001101100001111010000000111111011011000001101
result:
ok single line: '101001010000100010010100010001...1010000000111111011011000001101'
Pretest #6:
score: 4
Accepted
time: 4ms
memory: 111044kb
input:
6 300 299 299 15 88 170 221 223 223 186 88 128 128 274 286 186 248 227 227 128 142 256 286 35 289 232 230 107 35 289 227 265 222 42 230 163 208 276 265 259 6 265 6 95 230 19 230 37 276 289 184 181 268 183 96 219 95 43 230 115 230 112 249 215 43 215 230 204 110 218 230 296 87 276 126 87 262 126 262 1...
output:
11000010110100000001000111000100010111000010100111110001000110000000000010100011010011100001111000111101101000000101010110100110010110011010111110011101110100011100110110000000011111100000010001000101001001001000101110100110110011110001001100110010111101101110110100111100110110101110101111101101001
result:
ok single line: '110000101101000000010001110001...1100110110101110101111101101001'
Pretest #7:
score: 4
Accepted
time: 272ms
memory: 128940kb
input:
7 398 157212 329 222 101 134 287 349 338 326 235 220 323 81 358 260 352 7 127 308 224 340 122 333 70 150 219 15 249 355 250 260 236 322 302 95 215 371 264 230 27 190 222 247 227 93 130 14 75 95 267 330 221 35 88 117 189 275 291 28 119 330 151 258 311 207 315 73 280 13 388 32 13 16 82 44 295 301 299 ...
output:
001110000111100010111101000010000001110111011010110100111100011110000101101000111111010001111001001000101111101111010010010111011000111011111011010100010101001110111000001110001111001001001111111100011010000011111000100101110010000110010000110000000100100111111111100111100100111101011100010100010000...
result:
ok single line: '001110000111100010111101000010...0100010010100111111111110001101'
Pretest #8:
score: 4
Accepted
time: 253ms
memory: 127256kb
input:
8 400 158802 285 220 116 190 316 363 128 235 119 7 75 194 346 134 186 74 394 337 57 347 370 27 139 313 379 296 149 63 112 161 259 383 136 102 43 241 95 187 273 317 13 151 288 318 179 70 327 76 368 135 336 202 115 166 261 238 390 11 167 296 383 84 149 263 114 26 2 309 45 255 17 171 176 1 243 10 109 2...
output:
011101010111110111000010101101010101000110010100111001111101110001101101101011100110101110000000010111000001110101110001111001011111010001110001000101100010100110000111000101110101100001111001001011110100101101101010111100011101011001101000111000110000100111110110110011110011011111101100100110100011...
result:
ok single line: '011101010111110111000010101101...1001010010111010111011000111110'
Pretest #9:
score: 4
Accepted
time: 14ms
memory: 110152kb
input:
9 1998 1998 1 814 365 1 86 1 753 1 642 1 97 1 575 1 1238 1 1 366 1 1241 1 1017 1621 1 1 1718 1623 1 1080 1 1 518 376 1 457 1 1 1585 371 1 435 1 1 979 1 26 6 1 1785 1 1 1771 1 798 1 13 1 1396 1 734 1 1510 1962 1 1 593 1 677 1 881 1 483 1 786 1 32 1 428 1 1837 1 595 1 1880 409 1 1328 1 1 1051 443 1 1 ...
output:
011000110001001010001010000000000000000000000000000101100001000100000001101000100111000010000010010011010000010001000001001110010100001011010111010000001100010010000000011101010000011000000000000000100001001110000010100000100110000110010000100001000101000100000101001000110011110101111011100100000000...
result:
ok single line: '011000110001001010001010000000...0100000111010101001010000010010'
Pretest #10:
score: 4
Accepted
time: 12ms
memory: 110176kb
input:
10 1999 1998 1 873 659 1 1 1387 1635 1 1 1388 1 1646 1 691 1 1389 1741 1 818 1 1 1790 1925 1 1 142 251 1 1 1074 1 1226 1579 1 1 221 58 1 1 662 414 1 1630 1 1914 1 1 290 1 645 1 1443 1 750 1135 1 1 66 1 991 1 924 1 671 528 1 1 740 1 1347 603 1 1 457 1 130 1576 1 861 1 1 1553 1 1327 1 1056 1073 1 149 ...
output:
010000010000000000000000000001000100000100000000100000101100000001000000000000110000001100000000000000000100000000000000010001010001000010110001001100011000010000011001100000100010010000000001011101001000001000001001000000100000000001101000110111010100000100000000001001000000000001110000100010010000...
result:
ok single line: '010000010000000000000000000001...1111000100000100011111100110000'
Pretest #11:
score: 4
Accepted
time: 8ms
memory: 112868kb
input:
11 1999 1998 331 1835 1142 848 741 1005 1142 1687 1005 1515 152 1142 964 899 1142 1760 1427 1515 625 1427 183 1381 1142 181 11 183 575 1142 1427 1462 237 1202 1314 183 237 1462 1130 237 1314 884 48 1555 1542 884 560 1130 1516 1142 1130 1414 357 1142 1967 1885 1414 1680 1885 884 1414 645 1142 1488 18...
output:
000000001010010111101000000010000100111011100101000110001101101001011000111111010111100111000010000111001100111101000101101010101100101000101000110000100011000100010110001101010101011010001000101001000100100001100001101101001000011100001001011100001001000010111010000101111000000100110100100110010000...
result:
ok single line: '000000001010010111101000000010...1101110101001100111110100101110'
Pretest #12:
score: 4
Accepted
time: 15ms
memory: 111460kb
input:
12 1997 1999 1029 661 341 336 1029 1481 411 835 1086 1266 97 500 264 1481 1139 264 1547 1139 1665 547 861 1043 140 367 1696 484 263 835 778 1665 1665 701 501 263 992 1761 1547 861 1705 341 1493 501 1017 1493 221 1017 1661 1 861 1836 1191 1836 372 1191 1623 1191 221 413 1479 1558 1894 413 1392 1208 1...
output:
110001111011110111011111010101101011001000001010111001011100001001110100001111000011110100001110101010111000100100000010111011101110000010110000110010010011100001100000000000001010011111111110000101010010010100100000101001010100010010101001011101010010111011001110100010001010100011101001001100101011...
result:
ok single line: '110001111011110111011111010101...0011101101001101111100110011011'
Pretest #13:
score: 4
Accepted
time: 11ms
memory: 112672kb
input:
13 2000 1999 315 1468 994 1618 181 1154 422 1318 1618 1045 898 422 627 1164 716 181 1453 802 898 863 615 863 1618 1412 1529 229 875 615 1969 1618 1585 615 1748 1884 1585 1748 1295 1495 1618 1567 1748 320 716 1951 1164 1928 1995 320 300 1618 1995 996 1504 1618 833 1995 1951 1742 1228 1742 466 1228 37...
output:
001101010010000110100001000101110001111000010011010011011011111010101111011000010111100011111010110010101100001010110010110110010011010010011111100100010000101111011010010011111000110101001001000010101010001011010001111001010000100011100100001010000010100010011010100010111010111101110100011010111001...
result:
ok single line: '001101010010000110100001000101...1110010110011010101101110001010'
Pretest #14:
score: 4
Accepted
time: 14ms
memory: 110080kb
input:
14 1999 1997 1428 1975 1278 428 542 1697 1267 542 96 1428 1818 542 542 1275 1912 428 1902 1203 864 793 1912 793 793 134 1514 542 1428 1662 1845 1662 363 1687 134 964 1845 1404 277 367 42 403 436 1404 134 1273 1405 1165 1017 436 1547 1273 84 1017 1327 510 407 1017 542 374 1862 1362 542 1690 1359 1450...
output:
100000011000001100011011100100011101001011011011010101011111111111011000000000101101101100000101000000110010111011011111010111010000011101000001111000100010110000010111110010101111101111000110101000110111000010011111010010011101010001110100011010001010111000101000011111000011000110100001100100100011...
result:
ok single line: '100000011000001100011011100100...0000011101010101110001110111111'
Pretest #15:
score: 4
Accepted
time: 205ms
memory: 135528kb
input:
15 99998 99997 1 96995 7146 1 1 18611 46501 1 1 10868 1 55590 70711 1 77138 1 19004 1 1 90680 1 11182 27315 1 70017 1 97507 1 1 31756 78834 1 64395 1 57108 1 1 34606 59783 1 32613 1 1 46091 1 78793 1 55495 1 74593 1 74172 61751 1 72947 1 73899 1 1 58605 1 73275 1 47218 52264 1 1 8195 1 42357 16623 1...
output:
000100000000100001000000000000010000010000000000001001001000000000000000000000000000000000000000010100010000100010000000000000010000001100100010000000000000000000000000000000100000000000100000001000000001000000000000000010100000000100000100010000000000000010000110001000000000001010000000100000100100...
result:
ok single line: '000100000000100001000000000000...0011000010000000100100010101011'
Pretest #16:
score: 4
Accepted
time: 203ms
memory: 136312kb
input:
16 99998 99998 12935 1 1 82068 31478 1 1 35053 30682 1 26284 1 57086 1 84707 1 1 94973 1 20290 1 40000 94289 1 1 4659 1317 1 1 43167 1 3986 1 42240 1 75964 1 50567 1 75458 1 23876 76541 1 7943 1 1 47255 99891 1 24704 1 36109 1 1 47064 1 64127 18166 1 1 83989 1 8601 88088 1 97554 1 22084 1 72740 1 1 ...
output:
000000000000010101000000000000000000100000000000000010000000110000000000000100100000001001000000000000000000000000000010000000100000000000000010000000100000000000000000000000000101000000000000010110101011100011000001000000000001000000100110000000000000000011000100010000001100000000001000000001001000...
result:
ok single line: '000000000000010101000000000000...1110000000000001101010011010000'
Pretest #17:
score: 4
Accepted
time: 267ms
memory: 136896kb
input:
17 99998 100000 50028 25083 4028 68219 70565 25083 59494 70565 66114 93944 4028 84692 88423 59494 26781 73219 21455 98311 4028 88506 95224 42975 95224 66114 7138 4028 53446 35541 64661 55427 73219 88423 24078 80464 11742 95224 34936 4028 31313 4028 57956 11742 35830 92766 18941 4028 32614 32149 4685...
output:
001110100011101101001101110000000011100100111011101101000101001110001001000010000111110011101010011010010100111100111111101010111111111010001000101010111001110011111110000101010001101101100100101011100011011001000111111100001111001100010011000010100111000001111000001000010011101000000111010111101110...
result:
ok single line: '001110100011101101001101110000...0110111111001011010100101100110'
Pretest #18:
score: 4
Accepted
time: 250ms
memory: 136436kb
input:
18 99999 99998 51760 25210 4972 25210 28168 28253 48755 4663 78459 53517 9224 25210 42723 14824 9224 42723 99143 123 12539 13283 64179 42723 61514 48755 25409 88964 23435 64179 47409 48755 63385 47409 63385 97335 95604 97335 13283 86017 95604 71762 13283 97992 32214 23435 93347 95604 34992 13283 933...
output:
001101101010111101000110010000110111010010111111100001001010010011111100110001000101000100011101010111010100111000101011001100011001000110110001001111000111110111100100101101000101000001011001100001000101010100100011000110010001010001111110100010001101101101110011101100101110011011110100100101101000...
result:
ok single line: '001101101010111101000110010000...1111101010101011011001011010101'
Pretest #19:
score: 4
Accepted
time: 591ms
memory: 163212kb
input:
19 200000 200000 11395 40052 85793 106727 4123 79977 11395 142227 142227 182842 85685 41633 112252 98876 106727 57716 6354 182842 14531 126196 163204 167558 66055 112252 177201 174123 34685 26071 7419 143512 124681 112252 107232 6354 107232 99631 106727 183055 106727 137319 49824 106727 79547 100987...
output:
100001101000111110000000000101110001000001100100000110001011101000010010111100101011000110000110100010101010001110001100110010001111100100100001100110000011101111101001111110010100001011010101111010010111010110101001100101101111001100100001101110110011011111000000011000001000101111111110001101010000...
result:
ok single line: '100001101000111110000000000101...1001011111101110110111110101010'
Pretest #20:
score: 4
Accepted
time: 607ms
memory: 162572kb
input:
20 199997 199998 169686 52645 53429 38909 63634 164966 51624 103627 53429 53576 128410 164966 148972 28321 186742 151263 24251 138408 105355 93124 186742 32946 116282 182563 14538 53429 78133 83730 53429 15313 112387 31418 53429 25082 53429 112868 32946 37925 172385 177129 53429 32706 33610 175095 5...
output:
100101110100010100011110110101100001011100001110000011100001110000110001100110000011101011000010011100101011001001010011101000010110001100001100100010111000010000110111111100100110001100000001101101001110100110101011011011011100000000001011000011010100000101011101011000011111110001010100101101001111...
result:
ok single line: '100101110100010100011110110101...1101010110011111010101011010101'
Pretest #21:
score: 4
Accepted
time: 588ms
memory: 163500kb
input:
21 199998 199998 122496 149651 20979 14815 14815 77334 95220 186640 186570 110974 14815 113543 19628 71192 128252 189071 12366 186570 98432 165437 108280 122496 48687 73363 83482 28479 94845 178878 46110 88539 12366 28479 175624 28479 108280 48864 103372 141952 145766 81783 48864 145766 117912 13479...
output:
100110101111000010110100101011010001101110001101001101011101100101111001001001010100110100010101000001011100101010000000010010110111101110110110010101010111100010101011111010111100010100011100011110100110110011110100111101011010011110101000110100101010011111010101101010010101000001000000000101011011...
result:
ok single line: '100110101111000010110100101011...1110001100001001011011001011010'
Pretest #22:
score: 4
Accepted
time: 1943ms
memory: 242992kb
input:
22 499997 500000 334700 194098 129711 152039 244474 378172 71321 244474 15326 455599 440234 249557 41082 71321 364733 194098 453529 152039 71522 453529 348952 453529 348952 170356 180440 41082 180440 76314 103046 121168 76314 124996 313705 291781 248226 185921 175599 194098 187880 124996 313705 3489...
output:
001111101010101011011100100000010010000000001001110001001001110001000110000111000011100000100011010100110111101001011110110111001010100101101110011001111101011111010001110111010100111111000000111100111001010010011100010001110010101001011100011101010011010111110011001111101110011011110010001010110110...
result:
ok single line: '001111101010101011011100100000...1010101001100100010101101001110'
Pretest #23:
score: 4
Accepted
time: 2051ms
memory: 246104kb
input:
23 499998 499999 282875 302558 212923 282875 212923 438128 65425 73187 361498 385305 353276 73187 361498 435430 117284 387517 490582 353276 316766 438128 87290 316766 61957 437011 361498 189075 61957 87290 335411 266794 174313 177718 330621 303632 135495 472822 61957 303632 490582 174313 69822 20415...
output:
110001011111011101001110101010010001011110000000111101110111100000000101100110010011110010000000110111011101110100100000110101111101100000011100101011000000011111001101101010000100100010110111101010010100011101010010110011010010110001111110011010001101000000001010000100010100001001100110101000101011...
result:
ok single line: '110001011111011101001110101010...0010100011110110000000011011111'
Pretest #24:
score: 4
Accepted
time: 1962ms
memory: 242600kb
input:
24 499998 499998 60545 282694 437920 78125 102809 185302 437920 454236 266145 83562 83562 60545 375706 437920 106389 152881 223185 370648 152881 375706 175888 83562 370648 292053 175888 188591 338086 188591 370648 139316 152881 305921 102832 182832 338086 276554 370648 204126 466686 313153 341928 47...
output:
111001100110010000010001101011111101011111001011111001000000001101101011100011100000010011011001001011011000011001100001100010100001101000111001111101001100001010100000111011100110011010111010001110111010111010101110010101001000010101000000100011111100101000110011110101111010010101011110100111100010...
result:
ok single line: '111001100110010000010001101011...1100001111110111101110011011111'
Pretest #25:
score: 4
Accepted
time: 2061ms
memory: 239848kb
input:
25 499998 499998 52994 262703 381531 296092 408737 211620 408737 44516 390451 494879 68453 330221 21274 469837 336771 130685 137557 494660 336771 381410 343865 110140 354910 390451 470568 320952 381410 343865 408737 45925 26229 363670 11243 402429 343865 363670 465897 490951 390451 286136 474922 339...
output:
001101111010100010100000011000000101100000110010001111110001010010010100010001111111010101011011111110101101000111110011010111000110001101101010101101111001010111011111010000011110001000010111101010011100110100001110000101000011001010110111100001011011101100110000010110110111110010110111010010001110...
result:
ok single line: '001101111010100010100000011000...0110110100111110010001101011100'
Final Tests
Test #1:
score: 4
Accepted
time: 7ms
memory: 109624kb
input:
1 15 49 5 12 6 1 11 12 14 6 10 11 13 7 2 4 1 9 1 4 12 6 1 15 11 8 12 13 3 14 5 14 8 2 4 10 3 1 10 14 11 2 12 6 13 8 3 10 14 10 11 14 3 4 13 4 1 7 12 10 5 11 6 8 13 15 11 4 11 13 15 5 15 3 14 1 3 7 6 2 1 3 9 13 6 5 2 5 2 10 2 14 6 3 4 1 7 2 2 11 11 6 15 14 15 2 13 11 6 10 13 3 1 10 14 15 12 13 9 12 1...
output:
00010000010010
result:
ok single line: '00010000010010'
Test #2:
score: 4
Accepted
time: 13ms
memory: 112048kb
input:
2 15 49 9 6 14 12 1 6 1 10 15 8 7 8 7 12 2 9 1 4 14 13 3 10 5 11 11 9 9 13 3 12 14 1 2 5 10 13 7 9 15 14 11 7 8 11 14 13 4 7 14 11 14 3 4 8 7 11 3 2 9 3 11 15 11 6 5 10 12 3 8 12 8 14 1 15 3 5 14 8 11 1 1 4 6 3 12 6 6 15 10 8 11 8 15 4 9 7 9 13 11 13 8 4 9 5 2 11 7 3 14 7 10 11 2 8 8 13 7 14 7 10 6 ...
output:
00000001110011
result:
ok single line: '00000001110011'
Test #3:
score: 4
Accepted
time: 11ms
memory: 109836kb
input:
3 15 47 1 13 9 1 7 12 4 3 2 12 5 15 5 8 14 5 1 3 11 6 7 6 5 3 7 10 12 14 15 5 15 8 7 10 4 11 9 3 10 14 15 6 15 11 12 8 5 2 12 7 9 8 15 10 14 11 7 4 12 3 5 13 2 8 6 13 1 6 14 3 1 14 2 1 10 15 8 10 8 9 5 14 9 11 14 13 8 3 10 3 8 12 13 2 12 9 13 5 1 12 6 2 3 2 14 8 11 4 7 3 7 13 13 10 4 3 9 1 5 12 10 1
output:
01010010000111
result:
ok single line: '01010010000111'
Test #4:
score: 4
Accepted
time: 4ms
memory: 110856kb
input:
4 299 299 227 134 217 258 59 90 264 227 211 52 227 44 152 277 271 96 174 258 12 284 150 290 91 44 44 53 135 211 169 135 226 169 242 53 278 242 163 258 273 278 126 286 196 278 150 271 258 297 124 196 258 65 100 126 59 201 258 220 159 280 159 226 30 258 159 57 198 124 261 198 57 213 103 261 103 47 213...
output:
1010101101100111110011101000011001101100111010100001111100111011001011010001100100000100111010100110011110000011010101001011000000010110010000101110000010101110111010001110010000000101100111111111101001110110111110000001111000001101100101001111010010011010100000001000010101111010111010110001011010
result:
ok single line: '101010110110011111001110100001...0010101111010111010110001011010'
Test #5:
score: 4
Accepted
time: 3ms
memory: 110744kb
input:
5 298 300 122 231 187 89 184 117 227 231 270 275 109 292 85 2 193 85 227 266 55 222 50 193 268 150 227 268 256 113 246 268 50 256 246 49 80 49 80 186 275 155 256 121 15 121 186 283 217 25 145 117 33 191 135 117 117 12 101 117 117 179 277 62 238 293 169 46 15 293 277 292 241 293 186 33 21 117 217 117...
output:
010100110111011001010100010100000011000001011011011011101001101000111100010001101000001011010110001011111010111011110001011001101010000011101000010010000100100100110111100100000011011000110101110111001111001000111010110100011001010010000011111010011111101000001111100011011110010010010101110000100
result:
ok single line: '010100110111011001010100010100...0011011110010010010101110000100'
Test #6:
score: 4
Accepted
time: 15ms
memory: 110588kb
input:
6 300 297 289 217 88 237 282 133 157 73 282 68 185 280 88 73 216 25 283 42 149 217 135 282 228 282 73 283 17 235 213 282 217 188 247 282 283 17 282 74 291 83 291 188 172 17 282 224 282 203 249 172 270 29 113 170 291 270 112 270 175 282 131 112 23 93 38 249 167 70 10 113 153 112 102 38 104 282 282 28...
output:
01000100100001001001110011101001111100011101111111011101010110010000111000101001001011101000001111010010101110001011001110110000101101101000010011000111011100010000101011011100000011001110100111010100111101010000010111110100011101010110001000000001110100000101011010010100110001100000010100011100101
result:
ok single line: '010001001000010010011100111010...0100110001100000010100011100101'
Test #7:
score: 4
Accepted
time: 262ms
memory: 126044kb
input:
7 400 158802 131 314 247 393 10 315 130 324 163 67 94 112 321 276 400 284 234 55 264 328 303 73 251 214 126 58 295 323 262 332 68 17 132 317 358 31 364 204 108 144 290 242 140 198 72 97 140 194 195 286 76 304 224 116 22 314 172 369 26 164 3 54 42 19 51 113 347 278 236 308 222 269 310 237 79 291 213 ...
output:
010010001000011100010101101000100011111111010101001000001011011100000101011101110011110011110110100000001100100100010110111001110100000100100001101010011001000010111101011110000001000010001111000010001111000000001100110011100101010011010001111100101100010110110100100011101100011010101111100111001110...
result:
ok single line: '010010001000011100010101101000...1110000110110001011111011101010'
Test #8:
score: 4
Accepted
time: 260ms
memory: 125276kb
input:
8 398 157212 23 382 345 123 148 111 276 132 91 359 264 204 371 6 207 9 87 323 318 385 134 131 161 283 202 378 46 395 375 314 85 109 155 303 279 174 116 172 82 281 247 263 171 136 94 53 304 96 118 394 122 70 239 116 294 161 197 365 184 342 232 211 158 170 397 237 342 91 182 32 187 295 225 186 210 66 ...
output:
010011010101111011101010100001101000110000100000000001011111001110110110001011100101110101100000100011011111110000110100111100101001111000011100010111000010000001001110111001001010000010011101010100110100001100100001100001110000110111000000101010100010101001011001000001010001110000111001000010010011...
result:
ok single line: '010011010101111011101010100001...0111110100001100010100100010100'
Test #9:
score: 4
Accepted
time: 8ms
memory: 111464kb
input:
9 1997 1997 1173 1 1 269 1383 1 926 1 1 148 1 56 1 1075 1 929 494 1 293 1 1 1285 1 1381 1 1020 1 1089 1078 1 1379 1 1 1480 845 1 1 198 118 1 1 63 1 512 911 1 1 210 1 1135 1 237 86 1 1 284 1508 1 1 830 453 1 1 540 1 1239 1 1440 700 1 1 801 1 1654 1 1120 1 1804 1 676 1 752 214 1 720 1 1418 1 62 1 1465...
output:
001010000000001000001001100000100000001010000100000000000000001000001001001010010000010000000000000101001110000011001000001001010001000100000000010100100001101000010011110000010100000101000000001100010000101101000011000000000000100010100000100000000000110110000000011000000000100011010000000000000000...
result:
ok single line: '001010000000001000001001100000...0000100000101000000010000100000'
Test #10:
score: 4
Accepted
time: 7ms
memory: 111232kb
input:
10 1997 1997 765 1 1016 1 1 555 1483 1 916 1 1594 1 1 788 1 1438 1 864 1622 1 636 1 1 1322 1 1740 1 1513 859 1 1 1177 1 1639 721 1 90 1 1 1644 1289 1 1 106 1 670 1 719 1 1768 1883 1 1 1394 1384 1 950 1 1 143 1871 1 1 1742 1631 1 1 653 1 1191 305 1 1 1833 1844 1 1 1800 440 1 1 1793 192 1 1580 1 1 699...
output:
001000000000010100010101100000010010010100011000000100100001011000101011000011111000001111100101000100011000001010010110001010011100011100001010000010000001010001100100000001011001110110100010011101010100100000000100000110000111000010110111101000001000110111100110101011010010101110100011000010011100...
result:
ok single line: '001000000000010100010101100000...1010000010010000101101110000001'
Test #11:
score: 4
Accepted
time: 10ms
memory: 109664kb
input:
11 1998 1999 620 29 95 648 123 174 143 1375 544 694 143 1028 1028 1362 620 1837 1185 380 734 1784 46 694 78 620 694 1118 454 1274 389 950 1028 689 826 1319 689 568 1595 568 1005 1390 293 371 1850 1450 1390 1595 714 841 1227 78 1390 841 1648 841 1953 1648 1276 391 1148 1227 1650 152 1953 1209 1931 69...
output:
100100000101010010101010101101000110011001111010110111100010111010101101001110101111100010110100100101100100001001000010010001100101111000101110010000100000010001000011100111000111111011110000010111101100110011001111100110101100010000010111100001110011000110011100111000100111010000000010010100011111...
result:
ok single line: '100100000101010010101010101101...1011011100011110110110000111111'
Test #12:
score: 4
Accepted
time: 8ms
memory: 110296kb
input:
12 1998 1999 711 794 1158 711 565 1181 231 532 1158 1039 641 565 461 1538 1205 565 1039 1144 560 1072 694 1538 1307 1538 1280 1144 482 565 1110 1865 1047 1307 358 811 1280 467 565 1726 1433 565 735 1222 836 565 1105 1280 1307 1176 565 278 90 980 210 565 1356 1636 1176 1543 1543 1327 1412 1105 416 13...
output:
110101000101100010000010000100110110001100111001110111000001111111100101000110101111111010011010100111001100100011011010110000100110001000000111001100001000101100101100011101000010110110100110011000110100111100101010101110100010011001000111100000001100111011101001111000111111101110111000010010101010...
result:
ok single line: '110101000101100010000010000100...1000110100000101101110110011001'
Test #13:
score: 4
Accepted
time: 8ms
memory: 110024kb
input:
13 1999 1999 1920 588 251 402 933 405 251 1716 197 371 804 251 1552 1467 743 405 1191 405 804 46 1552 1809 1870 46 1809 233 405 1814 1053 1809 1580 390 1713 101 1290 397 1734 391 52 1053 910 52 125 910 405 316 925 186 405 1908 333 1419 1379 674 620 405 125 400 598 23 1379 1870 1379 1072 1148 503 152...
output:
010011100001001001011110011000101111000100101000101111110111000010000101001101101010110111100101011101010100001000000011110100011111010101010011010001100110011011000101100001001100011110111110110001011010010000110010000001010101111001011010011001100101001101000110111101001110000100011101110000010111...
result:
ok single line: '010011100001001001011110011000...1101001010100110011110100111101'
Test #14:
score: 4
Accepted
time: 11ms
memory: 112408kb
input:
14 1997 1998 1158 1352 849 1193 1245 886 117 972 589 849 1158 435 849 188 689 1668 1725 849 849 763 1158 56 56 568 1425 1806 968 1737 849 1840 849 865 689 1262 1835 568 536 1835 1371 726 1261 1067 1036 1824 1383 1219 1067 536 849 404 1579 1963 560 262 172 833 1847 849 1262 1824 1667 413 1383 1323 18...
output:
101100010000100001110011011100101010101000111000010100011010000001010000100100111001000000010010001011010001101000111110011010110000100101010100010000010100110010010011010011010111010011110001101111110001010010000001010000010111010001010011001000011010011100001111100110110001011000100101000000011000...
result:
ok single line: '101100010000100001110011011100...1110001000011011000011110101101'
Test #15:
score: 4
Accepted
time: 199ms
memory: 135340kb
input:
15 99998 99999 43839 1 7082 1 86718 1 1 23311 1 33700 3034 1 1 72029 1 53468 96288 1 94075 1 1 13705 6426 1 1 16819 3204 1 99049 1 83600 1 1 1104 98471 1 1 58834 1 37442 1 51475 42900 1 1 38928 1 19064 33178 1 1 50538 13991 1 72693 1 51555 1 20148 1 1 12376 1 38122 32372 1 37563 1 95816 1 38463 1 52...
output:
100100000000000000000000010000000010000000000010001000000100000000000000011000000000001000010000000010000000100000000100000100010000000000000000001000000010000000000000001000000000010100100000001000000100100000000000001000000010100000000010010000000001001000000000000000010100000000000000010100100000...
result:
ok single line: '100100000000000000000000010000...0101000111011010010000100000000'
Test #16:
score: 4
Accepted
time: 208ms
memory: 136700kb
input:
16 99997 99998 1 96613 1 57491 1 2815 88586 1 1 20908 38497 1 46861 1 34890 1 355 1 1 38354 1 78262 49482 1 96087 1 1 633 3167 1 75406 1 81355 1 1 97050 50430 1 11676 1 92336 1 52194 1 1 6921 1 2897 1 8914 1 82500 67126 1 1 79737 23206 1 1 15812 4858 1 24846 1 1 95545 1 56308 1 68244 63783 1 1 97933...
output:
000000101010000000101100000000110011100010001110100000001000100000001000000010110100101110011000000000100010100010011000100000000000010100011111100000101000000000000010010100000000000011010110000001000010000000001000000100110000100000011011000000011001000100000000000010000000000001011000010110000100...
result:
ok single line: '000000101010000000101100000000...1010000011000010011001110110000'
Test #17:
score: 4
Accepted
time: 275ms
memory: 138384kb
input:
17 99997 99998 95692 99774 97455 83287 46138 58393 8537 83249 34978 77087 83923 77087 13590 62176 15043 35418 62176 83923 11385 62176 98658 49648 83249 95692 46138 31839 5855 62834 46138 93442 5855 83249 90568 18505 55153 5855 33422 10110 11385 17966 46138 36078 43601 39378 93060 17966 58398 55153 9...
output:
110001011101010101100111011110010001101101110011110000010011000111011111101011111111110101111000110101010010110111001101000010100100011100011101001010010101001001100001010111101001011000100000001100111001110101101101111110101100110001111000000001111000110011111011100100000111110001110011110101100010...
result:
ok single line: '110001011101010101100111011110...0101110110010011111010001101111'
Test #18:
score: 4
Accepted
time: 249ms
memory: 136152kb
input:
18 100000 100000 96812 33313 54538 89815 76834 89815 30355 48968 75513 77899 99628 46426 27777 4816 51589 56128 5159 99628 67298 76568 64533 73206 84076 68220 84076 5159 87669 84076 78521 56303 89815 73206 24862 1196 43800 70150 70237 71625 56442 71625 64197 52450 71625 17408 43248 85455 80660 17651...
output:
100001001101111011000011000000010010001100110001000111101000100101001100010010010100001111101101110111000101101111001001010111000100011011011110110110100101010000101110110111001001011101000011111011100111101100011010110001001001011001010000100111110110011001001011011001110111101101010001000011011001...
result:
ok single line: '100001001101111011000011000000...0010110011010110000100100100110'
Test #19:
score: 4
Accepted
time: 656ms
memory: 163532kb
input:
19 199998 199999 131429 29117 173636 53542 170393 193318 28427 179420 113013 28427 120744 13539 102505 178545 173119 113013 99532 48135 168672 173636 16860 168672 146888 16860 166039 146888 14038 29117 65509 173119 124403 65509 150638 192293 73699 8527 37655 52828 81356 123054 190157 120050 169213 1...
output:
010110111111101100111100011010101111011000100110010110100011100110000011100110110010001010011101110110100000011011000001101000100010100010110100111101111100001101100100000110100101001110101001111101101000100001000111110000010110010101101100011100001001011100100011110000110110111001101001001101101111...
result:
ok single line: '010110111111101100111100011010...1010010010100010111010001100011'
Test #20:
score: 4
Accepted
time: 638ms
memory: 163272kb
input:
20 199999 199999 182311 55604 146866 106665 99564 147042 92457 22841 128364 166873 124471 92457 47994 174222 22535 6143 128364 16183 92457 42760 47994 146866 84444 128364 35207 92457 80823 59188 2867 12717 5210 108089 84444 3614 137221 199196 156785 169964 197681 171397 47994 197847 197847 91121 143...
output:
111010110011011101110000000101010111110110101110100111001111100111000101010111110010001001111000110011110101011010011000010001101100100111010010001100011100000110010001101001000111010010001101111111011101000111111000001001011110011001100010110000010110001100110001101001011001101001001111000100110111...
result:
ok single line: '111010110011011101110000000101...1110111000010101011100110111000'
Test #21:
score: 4
Accepted
time: 612ms
memory: 163016kb
input:
21 199998 200000 94528 157590 25847 86707 97590 162540 198505 102481 41463 25847 162507 97590 128300 180068 147204 97590 25847 139177 69050 145443 25847 136310 25847 57578 14140 70076 25847 64362 164289 15354 14140 13485 8282 182149 161847 119638 147204 88960 113854 88960 13485 8282 72674 25847 2584...
output:
101000010000101010010101010011101000100000011011010111111001010111010001010111011000110010110100010111101001000111101010101001010110000001111111100101011111101101010100101100000000111000000010001000011100011101010010000100111011000111011110011001111010011011000100001100000001000101101101101001100001...
result:
ok single line: '101000010000101010010101010011...0101011010010101000101011100111'
Test #22:
score: 4
Accepted
time: 1982ms
memory: 244192kb
input:
22 499998 499998 280377 483878 266009 112815 280377 326519 69573 244967 168348 273813 110734 241656 266009 207305 382472 326519 22088 183297 460568 274059 22088 497570 133515 382472 193021 171147 402251 452419 490201 176294 168600 133515 256006 497570 49038 266009 326229 256006 326229 128319 284102 ...
output:
100110011101111010100100101100100011111101001010100001100000011110010000100010110100001110110100111111001100111001110000110100000110010000010010101001101110000110101101110111111011111111001100100101010011110000101110100010111101010100110011100010000011001001101011000111111111001001010110100101110011...
result:
ok single line: '100110011101111010100100101100...1100000011101110001110011010011'
Test #23:
score: 4
Accepted
time: 1954ms
memory: 242928kb
input:
23 499999 499998 259202 41990 422273 407093 476537 77718 312194 46656 93178 302210 58543 312194 451246 12305 455228 172264 284596 361623 57825 361623 390474 324910 396929 58543 58404 451246 402456 307946 231928 44782 58404 402456 55707 361623 402456 28120 361623 33341 264073 28120 279978 144868 6191...
output:
011111110011111000010101100010100011100100001111001000000000110000000011010100100100000001101101000111011100000100010000111010000011001110110000110011110000000100010011010000000001001000111000011001011001010000111001001011101011011010000001010100111111111000110000111000100100100110011111111100111111...
result:
ok single line: '011111110011111000010101100010...1110011111110111101010001110011'
Test #24:
score: 4
Accepted
time: 2100ms
memory: 244032kb
input:
24 499998 499999 455819 459416 29084 235040 334831 299357 172661 463187 175914 157450 243243 698 175914 246603 29084 468425 29084 268222 29084 478039 235799 334831 393192 248511 407177 245137 29084 479214 235799 407177 142922 180138 487490 95999 318185 407177 352825 29084 348520 318185 298781 214562...
output:
101110100011100111011000011100011111001011001010100110100001110111111001001010100011010000101010010001101010011010101111111101101100111101110110011000110000011011101010011100111101000100100100110011011011101000010001101100100101000000000101010010110000011100111110111001011000100110010001101110001001...
result:
ok single line: '101110100011100111011000011100...0100011001001110101000001010101'
Test #25:
score: 4
Accepted
time: 1986ms
memory: 245688kb
input:
25 500000 499997 77293 201356 205334 145728 23314 145728 355098 183074 406179 145728 77293 355098 415236 293229 195707 453288 247155 179918 355098 198097 294421 198097 181199 393293 484579 345161 136685 348398 181199 198097 188759 181199 188759 319023 93778 8029 1079 319023 222413 453288 441529 2526...
output:
100110101001011101101101011000000110011101110011111010011000000011111010110000101110110101111110111111000110111000111000110111110100000110111101011100001101010101110011100110100101101010111011100100101011100000011000101110110001101001101001000000110011100011011111000110011110000100001111000100111010...
result:
ok single line: '100110101001011101101101011000...1101100100101000101110111010011'
Extra Test:
score: 0
Extra Test Passed