QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#371964 | #3320. Colorful Tree | PetroTarnavskyi# | AC ✓ | 325ms | 34304kb | C++20 | 2.9kb | 2024-03-30 18:43:14 | 2024-03-30 18:43:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int LOG = 17;
const int N = 1 << LOG;
VI g[N];
int par[LOG][N];
int tin[N], tout[N];
int d[N];
int t = 0;
void dfs(int v, int p)
{
par[0][v] = p;
FOR(i, 1, LOG)
par[i][v] = par[i - 1][par[i - 1][v]];
tin[v] = t++;
for(int to : g[v])
if(to != p)
{
d[to] = d[v] + 1;
dfs(to, v);
}
tout[v] = t++;
}
bool isParent(int v, int p)
{
return tin[p] <= tin[v] && tout[v] <= tout[p];
}
int lca(int a, int b)
{
if(isParent(a, b))
return b;
RFOR(i, LOG, 0)
{
if(!isParent(a, par[i][b]))
b = par[i][b];
}
return par[0][b];
}
int ans[N];
set<PII> vals[N];
int color[N];
bool checkSubTree(int v, int col)
{
auto it = vals[col].lower_bound({tin[v], -1});
return (it != vals[col].end() && it->F < tout[v]);
}
void add(int v)
{
int c = color[v];
if(SZ(vals[c]) == 0)
{
vals[c].insert(MP(tin[v], v));
return;
}
if(!checkSubTree(v, c))
{
int ver = v;
//cerr << "up ";
RFOR(i, LOG, 0)
{
if(!checkSubTree(par[i][ver], c))
{
ans[c] += 1 << i;
ver = par[i][ver];
// cerr << i << " ";
}
}
//cerr << "\n";
//cerr << v << " " << par[0][ver] << "\n";
ans[c]++;
}
int oldLCA = lca(vals[c].begin()->S, vals[c].rbegin()->S);
vals[c].insert(MP(tin[v], v));
int newLCA = lca(vals[c].begin()->S, vals[c].rbegin()->S);
ans[c] += d[oldLCA] - d[newLCA];
}
void remove(int v)
{
int c = color[v];
int newLCA = lca(vals[c].begin()->S, vals[c].rbegin()->S);
vals[c].erase(MP(tin[v], v));
if(SZ(vals[c]) == 0)
{
return;
}
if(!checkSubTree(v, c))
{
int ver = v;
RFOR(i, LOG, 0)
{
if(!checkSubTree(par[i][ver], c))
{
ans[c] -= 1 << i;
ver = par[i][ver];
}
}
ans[c]--;
}
int oldLCA = lca(vals[c].begin()->S, vals[c].rbegin()->S);
ans[c] -= d[oldLCA] - d[newLCA];
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
FOR(i, 0, n - 1)
{
int a, b;
cin >> a >> b;
a--; b--;
g[a].PB(b);
g[b].PB(a);
}
dfs(0, 0);
FOR(i, 0, n)
{
cin >> color[i];
add(i);
//cerr << ans[color[i]] << "\n";
}
//cerr << "\n";
int m;
cin >> m;
while(m--)
{
char x;
cin >> x;
if(x == 'Q')
{
int c;
cin >> c;
if(SZ(vals[c]) != 0)
cout << ans[c] << "\n";
else
cout << "-1\n";
}
else
{
int v;
cin >> v;
v--;
remove(v);
cin >> color[v];
add(v);
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 84ms
memory: 19300kb
input:
51180 6005 22052 37149 32700 8673 34267 50599 12143 5769 16174 25845 21032 23217 22045 51133 13468 39268 7448 12027 39881 35259 5925 25929 15755 41428 32476 44305 22560 35663 22735 28630 401 38413 40435 22313 12058 2115 35459 47570 44016 29422 9756 37139 45522 17680 38017 41869 11445 18715 44780 500...
output:
245 188 271 354 286 254 346 199 243 250 236 190 274 281 156 247 274 208 254 330 213 274 236 257 241 235 266 199 209 255 249 259 326 346 200 301 191 297 166 339 206 256 190 298 243 243 250 243 243 311 330 329 201 256 237 351 190 248 253 282 221 181 243 232 208 309 331 261 213 234 209 292 230 225 279 ...
result:
ok 17661 lines
Test #2:
score: 0
Accepted
time: 81ms
memory: 14396kb
input:
25295 12410 19312 11257 662 7120 7393 22658 12687 11887 24921 16293 5938 15467 23046 5300 16294 10293 12151 1067 3453 18419 6027 24087 15745 23688 23629 17670 22752 11605 19686 3908 3751 15179 18701 20186 9403 22259 1209 15985 9762 3455 14483 24764 7735 8166 13428 23955 1520 21795 5216 15090 20777 1...
output:
318 278 326 309 244 328 340 435 250 421 304 274 274 231 294 296 333 320 345 309 211 267 200 278 260 345 322 371 235 320 266 320 236 247 353 388 288 243 355 326 296 278 270 284 235 301 240 251 334 375 328 242 353 383 297 310 350 317 253 304 292 258 270 364 337 300 322 313 313 313 361 253 432 353 383 ...
result:
ok 36973 lines
Test #3:
score: 0
Accepted
time: 20ms
memory: 16472kb
input:
35465 12202 25883 33105 17725 9171 30764 20411 24243 6067 27421 29929 23863 27476 12529 28182 24640 24729 19568 14958 11985 19526 11354 3486 25563 34721 30939 32576 9989 4298 440 35457 3306 21772 22628 3530 4969 1261 618 20131 7758 6193 7295 437 2845 2516 11384 7249 7927 31087 30680 13469 14191 1060...
output:
-1 0 0 -1 -1 -1 37 -1 0 0 -1 -1 0 -1 0 -1 -1 0 0 -1 0 -1 -1 0 24 0 -1 0 -1 -1 0 0 -1 0 0 34 0 -1 0 23 0 -1 -1 -1 -1 0 -1 0 0 23 0 -1 -1 -1 -1 38 21 0 -1 0 0 0 0 -1 -1 24 0 -1 18 0 0 0 -1 25 -1 0 -1 -1 0 -1 0 -1 19 0 -1 18 -1 -1 25 -1 0 0 0 -1 -1 0 0 -1 -1 24 -1 -1 0 0 -1 -1 0 -1 -1 -1 0 -1 0 38 -1 2...
result:
ok 1254 lines
Test #4:
score: 0
Accepted
time: 86ms
memory: 26168kb
input:
88270 43830 56016 6734 69802 8682 43510 6629 28149 8134 30940 5005 85441 18925 68180 38780 10048 81871 57415 28783 24366 24434 10056 83294 3541 20010 64402 33493 64382 76918 45160 17264 31566 28187 68046 74171 27147 22082 77902 46297 14110 65551 83607 79091 70863 17906 14915 70549 11910 19014 35859 ...
output:
40 26 0 0 31 -1 51 -1 27 65 41 45 0 30 44 62 -1 30 0 0 54 47 23 59 35 41 30 30 23 21 -1 41 56 49 47 29 43 20 0 -1 30 -1 24 -1 0 -1 52 30 69 -1 29 25 30 0 -1 34 35 52 -1 0 -1 -1 45 65 41 59 28 52 26 0 0 27 -1 70 -1 50 -1 66 -1 0 44 0 -1 -1 -1 29 52 29 0 30 -1 41 0 69 40 41 88 0 57 -1 65 43 27 31 28 0...
result:
ok 14114 lines
Test #5:
score: 0
Accepted
time: 277ms
memory: 28252kb
input:
100000 83567 93818 87684 81977 41108 35957 39578 62180 34392 50183 54590 77393 33306 60693 17774 85433 83182 2064 51957 61210 19558 60275 54769 288 44923 19193 81764 68963 99993 75342 2953 68871 6574 70513 16907 15153 22358 59445 19147 12070 76058 34976 36159 1674 82555 97268 63168 33708 70275 270 3...
output:
71825 71739 71825 71825 71825 71826 71738 71738 71738 71738 71738 71826 71739 71739 71825 71739 71739 71825 71739 71827 71738 71738 71738 71826 71827 71827 71827 71827 71737 71737 71737 71737 71827 71737 71828 71828 71828 71828 71830 71734 71734 71735 71735 71736 71736 71736 71826 71734 71826 71735 ...
result:
ok 50000 lines
Test #6:
score: 0
Accepted
time: 298ms
memory: 28200kb
input:
100000 23978 33146 12426 95773 25918 32087 45592 84787 79758 18653 38119 56549 18688 89468 21212 43330 16522 51740 29601 27762 6374 79673 29 39051 19028 70854 29751 62859 56222 97080 33702 88412 49645 80841 23452 91675 47672 12453 85112 6255 35178 26828 93668 43394 46172 53652 78587 30479 91364 8884...
output:
58841 58197 58841 58842 58372 58842 58843 58843 58372 58843 58843 58371 58374 58196 58844 58374 58374 58845 58845 58195 58374 58374 58375 58191 58845 58845 58376 58843 58193 58843 58843 58194 58842 58194 58842 58843 58373 58373 58845 58195 58372 58372 58846 58195 58195 58846 58372 58195 58373 58374 ...
result:
ok 50000 lines
Test #7:
score: 0
Accepted
time: 325ms
memory: 28160kb
input:
100000 11590 85618 26261 96064 15084 60506 29688 61578 35621 85011 5443 24405 91474 90985 20040 58377 93887 29760 75102 89550 45582 67179 78723 52056 76807 75001 18287 19872 28813 52685 5630 19380 11338 52783 22944 51434 91151 97737 93996 27279 80325 43065 25625 18443 92175 38700 5297 79952 8475 354...
output:
29482 29230 29443 29232 29248 29444 29482 29487 29250 29343 29236 29774 29484 29289 29345 29290 29345 29483 29483 29234 29289 29250 29481 29485 29485 29350 29134 29774 29136 29231 29777 29354 29252 29489 29134 29288 29231 29439 29352 29354 29132 29441 29353 29134 29290 29472 29293 29697 29474 29694 ...
result:
ok 50000 lines
Test #8:
score: 0
Accepted
time: 299ms
memory: 28160kb
input:
100000 232 62356 18453 44038 45012 59981 3613 70583 14612 63853 15535 51309 21146 75126 45315 62848 16132 49201 17463 88241 1037 77920 34195 56409 75502 2297 26160 91225 62640 36245 82239 3139 38910 73005 49441 88033 7377 27194 25385 59950 6045 40741 15334 71894 24372 61307 28240 57524 28771 57572 2...
output:
5845 5955 5682 5663 5789 5812 5909 5904 5670 5666 5969 5867 5801 5896 5807 5652 5604 5934 5819 5530 5927 5902 5877 5915 5662 6031 5533 5836 5689 5867 6104 5924 5974 5780 5874 5772 5824 5487 6068 5912 5925 5824 5921 5968 5770 5828 5870 5976 6037 5534 5950 5833 5957 6196 5706 5893 5718 5663 5702 5794 ...
result:
ok 50000 lines
Test #9:
score: 0
Accepted
time: 254ms
memory: 28168kb
input:
100000 86364 26012 49174 2690 91400 21142 11628 45025 22852 72416 98511 15014 46851 27545 10533 68816 34355 78984 21730 84609 26902 51666 73105 38238 671 43347 14933 60394 17220 42996 83109 46281 86358 82143 17787 66055 29529 45108 64407 86475 37647 80181 64252 51038 10364 84749 37020 78950 26025 71...
output:
1011 865 986 991 957 979 893 843 869 971 969 801 827 1058 904 982 816 896 929 940 934 950 905 939 866 869 909 978 874 734 1073 878 952 920 937 1031 954 900 905 1039 848 943 764 966 989 1000 895 967 823 903 942 862 995 988 842 1039 937 849 986 909 907 903 925 960 905 979 882 1015 923 812 897 896 923 ...
result:
ok 50000 lines
Test #10:
score: 0
Accepted
time: 199ms
memory: 28156kb
input:
100000 11199 74348 72324 47701 38742 26647 92896 25496 34734 59643 29688 76448 96118 53332 32518 71017 4420 78208 17876 61784 26583 27858 81486 54354 40098 80419 88812 45051 18836 53931 9984 85181 44345 72908 45270 30958 11030 63722 36130 66991 27753 45934 35146 4161 25478 72331 93506 40221 38837 48...
output:
105 102 145 58 135 170 116 149 149 171 126 145 139 131 57 144 86 148 43 125 162 161 118 91 165 162 170 101 120 136 166 154 159 110 150 120 134 91 149 158 140 136 109 119 181 135 95 187 93 178 88 107 101 152 148 161 86 139 106 171 109 85 147 134 103 114 111 107 82 131 163 156 141 137 191 121 190 203 ...
result:
ok 50000 lines
Test #11:
score: 0
Accepted
time: 123ms
memory: 28544kb
input:
100000 30609 16780 8073 47180 35026 57012 85070 4750 76661 52695 43981 85622 68867 86884 12492 57975 28494 88312 41609 35562 14412 41057 285 55478 10941 41084 99209 32108 43281 86474 20685 81233 10928 68938 24094 32096 19030 84661 94563 86404 5089 49605 84237 59228 5000 47980 81106 40731 9956 88071 ...
output:
44 31 57 0 0 0 26 41 0 0 50 0 71 28 0 27 0 25 40 0 22 38 56 41 0 0 11 52 24 18 25 0 0 56 30 29 40 28 0 45 26 0 23 0 31 0 58 0 27 0 26 43 31 20 25 21 30 44 0 0 30 43 40 0 42 0 30 0 27 0 0 43 0 37 0 42 52 37 28 42 23 25 0 0 55 0 26 28 69 0 42 26 0 40 44 0 43 0 26 27 39 0 37 42 0 65 0 29 30 0 57 0 0 44...
result:
ok 50000 lines
Test #12:
score: 0
Accepted
time: 155ms
memory: 33768kb
input:
100000 96764 89701 33066 1632 59363 58680 89975 22536 28250 56169 58753 4079 94562 149 52379 71927 95718 98550 72037 77381 63904 62729 28995 16224 63932 40196 16118 39774 67380 91871 55855 50934 65972 16549 77910 86978 71288 10403 7197 52085 73583 35699 55807 58578 6096 44425 8886 51200 96374 12245 ...
output:
99997 99997 99997 99999 99997 99999 99999 99999 99999 99997 99999 99999 99997 99997 99997 99999 99997 99997 99999 99999 99997 99997 99997 99999 99997 99999 99999 99999 99999 99999 99999 99999 99999 99999 99997 99997 99997 99997 99997 99999 99997 99997 99997 99999 99999 99997 99999 99997 99999 99997 ...
result:
ok 50000 lines
Test #13:
score: 0
Accepted
time: 169ms
memory: 32628kb
input:
100000 621 29734 26486 30044 75145 77221 57611 63535 86593 22853 77710 94273 67859 46834 44215 35494 58434 18076 69784 62900 78942 76957 62243 56393 52738 36411 45649 65194 69357 61023 20975 81765 87382 81115 27280 26201 95645 99796 82951 82242 8619 58539 75433 84581 36235 19164 66367 64406 46201 20...
output:
99997 99987 99997 99997 99987 99997 99997 99997 99997 99997 99997 99997 99997 99997 99997 99997 99997 99997 99997 99987 99997 99997 99997 99997 99997 99987 99997 99997 99987 99997 99997 99997 99987 99987 99997 99997 99997 99987 99997 99997 99997 99997 99987 99997 99997 99987 99997 99997 99987 99997 ...
result:
ok 50000 lines
Test #14:
score: 0
Accepted
time: 157ms
memory: 31596kb
input:
100000 72475 36957 51801 51931 61327 70742 23974 53133 14331 15687 82645 6170 77271 86744 88179 23108 70909 79051 79644 42758 37736 45170 35916 12189 60954 62538 70596 1518 10873 49697 36621 68463 76349 15579 34424 68383 31614 26555 31948 38691 90935 74922 42643 29946 388 38051 13388 32511 75368 871...
output:
99988 99968 99967 99968 99987 99989 99984 99987 99968 99987 99982 99987 99988 99988 99987 99982 99992 99984 99982 99992 99988 99992 99987 99967 99967 99987 99984 99967 99984 99987 99967 99967 99982 99988 99989 99984 99987 99987 99992 99982 99984 99992 99988 99945 99984 99982 99992 99984 99967 99967 ...
result:
ok 50000 lines
Test #15:
score: 0
Accepted
time: 176ms
memory: 33528kb
input:
100000 4050 14375 24950 9873 71569 64942 51607 35923 6719 48093 23858 36799 31753 10092 76924 68109 53519 74941 37394 29612 37698 18012 67251 89776 62914 78644 5025 8671 12043 78830 18254 4958 64549 32885 78263 87942 38403 1888 41785 93517 20294 88820 76381 1091 56948 68113 10557 59189 82320 23241 8...
output:
99946 99831 99905 99877 99734 99751 99626 99626 99651 99888 99721 99721 99763 99928 99937 99889 99807 99840 99630 99807 99475 99651 99916 99975 99970 99630 99932 99928 99703 99723 99920 99942 99970 99974 99920 99942 99847 99917 99888 99933 99828 99901 99719 99630 99803 99932 99627 99858 99703 99807 ...
result:
ok 50000 lines
Test #16:
score: 0
Accepted
time: 199ms
memory: 34304kb
input:
100000 7308 69698 77497 85238 42171 4401 43223 50683 70432 85625 60694 63439 14102 71790 54257 59649 60766 58241 59804 19900 23489 24846 92174 55452 61095 67639 69932 66979 99084 97915 7123 52449 44843 35475 60581 14212 63026 61210 42899 61601 79059 74006 22019 65913 59297 23970 86093 75849 75115 37...
output:
99437 97026 99847 98527 97921 96679 99824 99806 98915 98760 98526 98752 94891 99186 99172 94320 96324 96890 99390 96890 97654 97616 99756 98120 99295 97714 99437 99865 98304 97136 99168 98621 97623 97646 98387 95684 98129 95390 99571 99009 98766 99913 98851 97561 98918 99000 98045 98271 98445 94055 ...
result:
ok 50000 lines
Test #17:
score: 0
Accepted
time: 240ms
memory: 32176kb
input:
100000 59965 39568 52722 18791 47251 72909 55568 87421 44363 83875 31656 37871 97408 49964 31239 85741 71623 19889 7525 71006 13476 57298 27042 26819 61662 66898 94975 87984 58317 85994 52274 43506 12957 13644 85678 53054 12673 57137 59420 20941 52991 74324 62916 73124 45003 54893 91233 73945 11674 ...
output:
82300 94311 92199 83803 82169 62831 91345 84247 95838 84595 98120 55506 79432 83396 68912 88807 85903 86441 89479 70999 66691 85229 93448 78259 90757 88395 89704 98046 92860 83739 90000 84577 80199 71448 86199 86984 91561 87249 93226 89519 97555 81817 82641 89620 99310 93356 39865 96373 82020 91117 ...
result:
ok 50000 lines
Test #18:
score: 0
Accepted
time: 210ms
memory: 32292kb
input:
100000 85441 91779 85471 45140 15775 15163 25671 16885 82821 4914 87479 79058 6214 30927 73133 19783 39990 80703 52602 85058 8508 52507 47819 28628 60165 84834 70842 78644 9677 4386 14331 10879 5562 60412 85504 71255 59407 91943 3904 54998 17615 8400 36125 8534 37829 56294 80632 72987 82851 52760 60...
output:
0 48513 44139 0 14320 10687 48522 0 0 58603 66526 0 57795 25453 39392 14838 77892 0 0 57905 0 0 33110 0 3764 0 0 53366 0 35794 0 0 0 14169 42937 0 0 30115 26074 29927 0 27604 49814 92934 11657 0 61151 0 0 22242 23312 74097 61167 15982 56213 15696 57977 0 0 0 0 98307 0 76240 24100 71952 0 53025 17618...
result:
ok 50000 lines
Test #19:
score: 0
Accepted
time: 90ms
memory: 25192kb
input:
81402 52294 64924 66675 52630 65733 44108 27532 36334 10801 17325 79839 33193 73607 61980 38162 48144 66652 58102 18126 57334 57332 66383 46500 16478 70092 73102 39944 68793 58672 22421 51596 67395 43980 56725 26743 31786 70624 38316 29788 37627 35286 29694 39100 39518 50592 13683 77334 76966 23991 ...
output:
-1 0 0 0 -1 0 -1 0 0 -1 20 10 0 -1 24 -1 18 0 -1 -1 24 0 28 0 0 -1 -1 -1 0 -1 22 17 -1 -1 0 44 21 -1 -1 -1 21 19 0 -1 24 -1 -1 -1 -1 15 -1 0 -1 0 0 22 0 31 21 32 -1 0 30 0 -1 16 -1 16 0 -1 0 19 18 31 -1 -1 -1 0 0 -1 -1 -1 22 0 -1 22 19 -1 0 28 0 -1 -1 0 23 -1 -1 22 0 27 18 0 18 0 -1 20 26 -1 24 -1 0...
result:
ok 18677 lines
Test #20:
score: 0
Accepted
time: 44ms
memory: 18220kb
input:
43822 22040 3345 33193 12299 43789 33431 16646 25965 13495 6144 35213 26673 43514 34878 25168 14551 14964 33684 14124 34112 42978 38456 6635 11046 5589 23442 37659 5766 36297 38686 43544 12424 43221 26002 29393 33508 43040 20933 36104 13505 5104 1362 15977 40525 36729 6245 41477 39129 43266 7696 382...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 0 0 -1 -1 0 -1 0 -1 -1 -1 0 -1 -1 -1 -1 0 0 0 0 -1 0 -1 -1 -1 -1 0 0 0 -1 0 -1 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 17 15 -1 0 22 16 0 -1 -1 36 -1 -1 21 31 -1 0 -1 -1 -1 -1 0 0 -1 25 0 -1 -1 -1 0 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 0 -1 -1 -1 0 -1 -1 -1 -1...
result:
ok 16264 lines
Test #21:
score: 0
Accepted
time: 43ms
memory: 16924kb
input:
38443 17664 7616 21869 10802 37221 26655 30981 31037 1718 22435 11382 15741 31987 4787 14857 29322 29697 30985 33417 27079 327 22867 16634 23045 15416 30621 14770 21473 15366 2974 26178 3697 21367 1618 33614 790 15196 2740 3470 21401 34501 10800 17765 16125 13082 17292 14106 7594 12722 18377 4776 10...
output:
77 95 98 68 80 33 94 89 98 35 91 141 121 114 96 108 89 59 74 129 60 25 120 96 111 70 97 119 96 73 108 72 90 48 86 101 82 46 83 67 109 56 106 133 96 93 89 100 95 138 95 87 90 75 50 95 109 98 61 79 45 93 98 95 84 61 104 100 101 82 111 75 73 91 79 84 49 162 52 41 93 56 97 69 116 105 67 74 94 129 84 23 ...
result:
ok 9366 lines
Test #22:
score: 0
Accepted
time: 44ms
memory: 20420kb
input:
55278 35200 8013 43231 3072 8039 8474 15957 31645 50868 32656 46380 1804 82 34678 5428 17532 27905 21961 48094 48032 34459 54132 26520 26209 8550 44210 53504 7203 48792 18440 46617 44922 14323 22064 22129 36233 38750 51112 38810 34917 46595 26402 40308 47595 7355 7379 51548 4574 43809 2294 24733 394...
output:
-1 0 0 0 -1 -1 0 -1 -1 -1 0 0 0 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 -1 0 0 -1 0 -1 0 0 -1 16 0 -1 -1 0 0 0 -1 21 0 0 26 -1 0 -1 17 0 0 -1 -1 0 0 -1 0 -1 -1 0 19 -1 0 0 0 -1 -1 -1 -1 0 0 -1 0 -1 0 -1 0 0 0 -1 -1 0 -1 0 -1 -1 18 -1 -1 -1 -1 0 -1 0 0 14 -1 -1 -1 -1 -1 0 -1 0 0 -1 -1 -1 -1...
result:
ok 7188 lines
Test #23:
score: 0
Accepted
time: 310ms
memory: 28268kb
input:
100000 4584 47685 8828 61583 61380 81813 87616 82741 66045 68808 87907 86426 95446 65089 51633 59038 85631 60421 27974 20199 87014 42718 48926 89757 32444 40384 52639 73343 83308 7571 38273 86330 6774 95791 9793 2242 67561 52761 47511 72364 50913 43655 78178 52314 68813 26568 86298 58854 787 78313 7...
output:
69043 69533 69533 69533 69042 69042 69042 69042 69532 69534 69535 69536 69039 69039 69039 69039 69534 69534 69039 69534 69039 69535 69535 69535 69038 69038 69038 69537 69537 69538 69539 69034 69539 69034 69540 69033 69540 69540 69033 69541 69541 69034 69540 69540 69540 69540 69036 69036 69539 69539 ...
result:
ok 50000 lines
Test #24:
score: 0
Accepted
time: 311ms
memory: 28296kb
input:
100000 99593 70848 48267 58508 64265 77234 70420 70582 86836 9265 74438 61671 68364 11358 65314 30317 99651 95282 3917 30303 42791 76736 38572 3220 99187 68559 40357 10752 33413 24952 54243 55841 82336 6660 66460 76991 54562 61245 98241 27340 47968 14082 37140 79674 74568 53871 11094 58623 75129 666...
output:
54761 55133 55137 55137 54862 54862 54760 54863 55131 54864 54759 54760 54761 54761 55132 55132 54863 54759 54864 54868 54868 54759 55134 54760 54760 54865 55134 54762 54864 54762 54764 54864 54764 54865 55133 55134 55134 54763 54864 55134 54866 55132 55134 55135 54760 54865 54865 54760 55133 55133 ...
result:
ok 50000 lines
Test #25:
score: 0
Accepted
time: 319ms
memory: 28188kb
input:
100000 47921 26631 32675 46528 98413 87662 83121 28586 92901 91263 79574 85962 80673 6058 22187 14815 69519 26659 94157 46332 97965 92107 62949 75058 20351 68324 53337 52341 92179 11634 6776 28530 83447 42983 80469 38399 81744 1735 12729 7857 6796 2969 75404 77650 70487 2299 12942 76745 91258 83898 ...
output:
25612 25437 25852 25544 25647 25854 25438 25545 25386 25389 25548 25440 25527 25417 25649 25706 25613 25650 25549 25613 25709 25711 25441 25441 25527 25650 25845 25847 25712 25544 25651 25850 25851 25716 25656 25387 25718 25654 25424 25614 25386 25618 25542 25851 25444 25523 25657 25423 25384 25618 ...
result:
ok 50000 lines
Test #26:
score: 0
Accepted
time: 296ms
memory: 28272kb
input:
100000 42903 44337 72824 83060 11336 67244 98718 83510 29435 28152 79751 65000 40589 30416 57906 58671 90772 41317 35296 57756 97840 93682 79538 26635 56221 89818 58907 50048 79768 16149 43165 9071 42148 68522 39365 69420 44084 3914 43097 20170 99563 79027 72161 64799 30336 71443 2505 15472 55307 60...
output:
4854 4813 4876 4611 4785 4742 4621 4933 4452 4871 4429 4450 4721 4866 4788 4567 4453 4615 4828 4466 4854 4723 4537 4623 4590 4457 4831 4810 4908 4538 4807 4385 4790 4856 4770 4809 4479 4760 4714 4622 4455 4865 4638 4781 4680 4413 4458 4614 4416 4637 4461 4624 4792 4868 4646 4874 4462 4706 4731 4728 ...
result:
ok 50000 lines
Test #27:
score: 0
Accepted
time: 261ms
memory: 28372kb
input:
100000 8124 71177 99760 93144 26993 88243 43122 70802 71357 70740 24796 46388 35527 61419 53018 63514 34871 53077 58273 81460 58606 6654 36963 4034 85756 56031 79870 35145 70408 27959 62500 48701 21832 64779 45291 65368 30586 57989 90703 46748 31415 81699 2801 51880 81748 16067 46209 2012 74853 4873...
output:
727 696 688 714 607 675 764 758 652 795 744 658 668 687 641 618 648 623 826 674 700 687 696 658 694 710 619 783 628 726 888 735 660 693 597 738 642 660 724 716 674 775 570 741 708 706 744 728 784 718 698 779 633 778 643 630 631 640 742 768 634 719 671 737 693 734 736 634 850 734 655 721 705 705 690 ...
result:
ok 50000 lines
Test #28:
score: 0
Accepted
time: 203ms
memory: 28344kb
input:
100000 91495 38361 86887 44334 34303 71546 79549 42323 87159 96317 99198 8647 85875 92489 60576 12403 84924 18766 13566 1686 81532 17967 24858 11699 31335 22594 39470 235 79411 4289 89069 20351 922 4369 20346 70832 76940 7793 88456 60691 40439 78037 14368 21262 22830 6142 60409 85649 65094 58447 466...
output:
93 136 117 136 115 49 140 86 102 127 85 81 89 132 121 87 109 91 117 81 55 102 97 152 119 90 116 47 135 88 118 120 106 98 105 43 124 112 110 49 126 111 78 145 117 81 103 83 87 87 135 96 92 98 80 134 104 126 94 62 121 76 79 75 94 111 112 193 117 96 144 52 73 90 109 47 96 139 60 155 89 143 120 116 142 ...
result:
ok 50000 lines
Test #29:
score: 0
Accepted
time: 124ms
memory: 28708kb
input:
100000 95330 60244 19009 47169 29360 1370 97792 55301 44544 42524 46444 6636 22265 89452 92926 29051 30691 38290 20340 68261 26126 19615 22292 18371 85529 73376 44469 84186 6076 72819 7252 14838 39598 88019 87400 67029 15261 18468 46269 5577 87852 92452 53334 46636 10370 51624 86647 98769 98901 3006...
output:
24 0 0 0 17 0 0 15 32 35 20 37 0 0 39 0 13 0 18 0 0 39 0 41 31 45 26 0 28 0 0 29 0 0 0 0 23 38 30 18 33 28 0 32 13 0 0 20 13 21 0 41 21 18 0 45 17 26 17 0 16 0 13 47 30 25 0 14 12 19 34 26 21 14 28 36 22 24 32 16 19 15 0 0 0 16 30 31 0 31 0 20 18 25 0 20 0 23 0 42 0 0 0 22 34 13 21 14 16 18 23 0 0 1...
result:
ok 50000 lines
Test #30:
score: 0
Accepted
time: 102ms
memory: 32300kb
input:
100000 25971 16726 67972 75720 1658 17144 46653 78273 64993 28730 92885 30703 48269 39093 45098 60612 60433 21540 78518 55432 11294 71895 82798 96395 85272 21749 8887 39998 32809 98462 48238 83667 54620 54927 72638 64631 13621 5357 49159 80586 13625 44091 91352 84523 25026 578 51389 11779 26806 2261...
output:
50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 ...
result:
ok 50000 lines
Test #31:
score: 0
Accepted
time: 79ms
memory: 33484kb
input:
100000 27757 2879 24504 12356 57014 71593 23132 27710 33391 7043 93690 51197 40391 17435 66366 71745 40990 44552 72661 78387 73185 20394 41920 24137 59911 70821 59471 48627 79795 73539 60083 62733 6811 6183 86345 73039 32257 25547 63155 76690 9198 21399 5131 54879 29999 87265 23333 76694 79078 74709...
output:
99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 99999 99998 ...
result:
ok 50000 lines
Test #32:
score: 0
Accepted
time: 198ms
memory: 19032kb
input:
50000 1614 46052 19377 7 38269 3071 12626 31002 36199 25332 41664 37921 36901 25982 35774 7201 42895 35176 21035 11215 19382 39276 38578 25008 4254 19973 10574 10624 14846 44710 11031 39156 43527 38222 22499 43534 48757 34060 8665 23160 32007 11120 18747 1272 25984 8272 46170 40502 20366 28296 15621...
output:
0 21 36 39 51 64 73 82 93 102 108 119 127 132 134 139 147 150 156 165 183 194 202 207 214 222 229 237 242 249 258 264 266 274 278 282 282 289 294 305 310 318 327 333 335 341 346 352 355 362 371 374 384 386 392 394 405 414 417 422 423 428 433 439 442 444 458 465 467 472 477 483 484 489 498 503 505 50...
result:
ok 50000 lines
Test #33:
score: 0
Accepted
time: 182ms
memory: 19020kb
input:
50000 18329 9766 49189 12597 16391 21663 45029 11023 19966 24007 13157 35973 15210 24620 3356 387 34694 19249 17634 41685 28863 14461 28047 24415 25672 19382 43795 13047 29134 17991 12672 29149 48642 31672 5933 9344 13781 43463 13920 33512 6572 4104 49879 25010 18477 37109 14447 14742 43915 5698 186...
output:
49998 49997 49997 49996 49995 49995 49995 49994 49994 49993 49993 49993 49993 49992 49992 49991 49990 49990 49989 49989 49988 49988 49988 49988 49987 49986 49986 49985 49984 49983 49982 49981 49980 49980 49980 49980 49979 49978 49978 49978 49978 49977 49976 49975 49974 49973 49972 49971 49970 49969 ...
result:
ok 50000 lines
Test #34:
score: 0
Accepted
time: 249ms
memory: 28368kb
input:
100000 97083 20795 97083 60338 97083 63376 97083 41261 97083 42362 97083 49322 97083 88240 97083 65077 97083 69499 97083 49878 97083 61906 97083 69998 97083 60099 97083 96472 97083 74538 97083 74766 97083 69172 97083 22485 97083 64420 97083 69745 97083 14903 97083 74259 97083 2774 97083 64215 97083 ...
output:
49878 49879 49880 49881 50118 49882 50118 49882 49883 49884 49884 50116 49883 50117 49882 50117 49882 50117 49882 50118 50118 50118 49882 50118 49881 49881 49882 50117 49883 50116 50117 49882 50117 49883 50117 50117 49882 50118 49882 50118 49881 49881 49882 49883 50116 50116 49884 50116 50117 50118 ...
result:
ok 50000 lines
Test #35:
score: 0
Accepted
time: 251ms
memory: 28160kb
input:
100000 68538 59099 68538 23674 68538 97350 68538 70759 68538 57392 68538 54883 68538 79963 68538 54496 68538 50099 68538 61070 68538 14412 68538 2844 68538 13860 68538 4864 68538 30664 68538 95384 68538 86170 68538 44513 68538 10812 68538 91631 68538 13737 68538 80457 68538 43080 68538 60485 68538 7...
output:
33488 33397 33114 33114 33115 33488 33116 33489 33490 33491 33492 33394 33491 33492 33115 33491 33491 33115 33394 33115 33394 33116 33491 33393 33116 33117 33490 33491 33492 33116 33116 33392 33392 33492 33117 33118 33119 33390 33491 33119 33120 33121 33121 33491 33122 33492 33386 33122 33387 33388 ...
result:
ok 50000 lines
Test #36:
score: 0
Accepted
time: 230ms
memory: 28164kb
input:
100000 78255 14607 78255 63697 78255 95602 78255 2977 78255 60498 78255 11538 78255 65372 78255 12056 78255 76666 78255 43922 78255 14456 78255 97860 78255 35341 78255 82773 78255 10912 78255 79716 78255 65301 78255 47606 78255 38762 78255 81049 78255 8950 78255 45109 78255 61529 78255 14011 78255 3...
output:
10089 10138 10138 9901 9854 9941 9901 10139 9902 9903 10090 9854 10042 10043 10091 9854 10092 9927 9903 9945 10140 9902 9950 9903 9946 9855 10043 9926 9927 9950 9947 9927 9928 10091 9934 9935 10212 10092 9950 10093 10041 10042 9903 10043 9936 9948 10044 10045 10211 9926 9936 9949 9950 10139 9936 994...
result:
ok 50000 lines
Test #37:
score: 0
Accepted
time: 195ms
memory: 28240kb
input:
100000 85871 94876 85871 65608 85871 64068 85871 12725 85871 75047 85871 5756 85871 28186 85871 55207 85871 82239 85871 74231 85871 40927 85871 91466 85871 43499 85871 76452 85871 67361 85871 80209 85871 26569 85871 89699 85871 97396 85871 50924 85871 63470 85871 2045 85871 65370 85871 15771 85871 2...
output:
1052 985 1020 975 1022 1059 976 1019 981 981 1004 979 1020 996 974 1038 994 990 939 988 982 961 940 969 1038 973 983 984 1004 977 1025 1039 1032 1040 988 1017 974 1000 1006 989 989 1072 1039 1006 1026 1026 968 990 1060 989 990 1013 987 988 1035 1061 971 979 978 1014 967 968 989 979 1015 984 1080 101...
result:
ok 50000 lines
Test #38:
score: 0
Accepted
time: 196ms
memory: 28328kb
input:
100000 93958 68078 93958 62817 93958 78004 93958 11366 93958 82311 93958 81834 93958 22341 93958 78689 93958 54310 93958 39882 93958 56104 93958 52161 93958 42481 93958 54405 93958 16121 93958 77689 93958 26643 93958 88054 93958 79528 93958 39338 93958 39656 93958 52100 93958 10331 93958 5005 93958 ...
output:
96 117 115 107 106 106 99 81 82 93 112 103 121 112 93 101 120 100 104 116 95 93 128 96 83 117 96 94 94 106 83 100 103 94 106 96 113 100 107 96 104 103 93 114 114 113 101 114 101 92 109 99 102 115 104 84 108 122 94 99 98 87 99 109 102 95 111 99 91 106 106 95 85 118 95 94 99 103 105 87 123 115 95 98 1...
result:
ok 50000 lines
Test #39:
score: 0
Accepted
time: 155ms
memory: 28344kb
input:
100000 94135 63122 94135 93760 94135 48564 94135 7156 94135 67077 94135 51738 94135 36455 94135 60070 94135 93072 94135 70009 94135 76894 94135 39217 94135 84497 94135 58993 94135 47309 94135 26174 94135 57797 94135 57456 94135 72778 94135 11289 94135 66210 94135 22249 94135 26591 94135 97488 94135 ...
output:
13 10 7 12 12 12 13 12 13 9 9 11 9 13 9 9 12 12 9 6 15 12 10 9 10 11 12 12 15 9 12 10 9 11 11 12 8 10 10 12 10 9 7 9 10 11 10 11 15 8 9 14 8 13 9 12 9 14 9 13 10 6 14 8 9 16 6 11 13 10 6 15 15 11 13 8 12 18 8 9 5 11 10 16 18 10 8 9 9 16 13 14 11 8 17 11 7 9 13 13 7 13 10 11 14 10 11 10 9 7 15 12 8 8...
result:
ok 50000 lines
Test #40:
score: 0
Accepted
time: 112ms
memory: 28756kb
input:
100000 33476 69233 33476 39937 33476 36617 33476 82614 33476 49319 33476 31203 33476 34000 33476 13992 33476 48846 33476 97685 33476 73158 33476 79557 33476 7762 33476 72925 33476 63775 33476 33382 33476 99211 33476 55668 33476 65633 33476 4275 33476 59971 33476 22171 33476 29304 33476 41552 33476 8...
output:
3 4 2 0 2 3 0 3 2 4 2 0 3 2 0 0 0 3 3 0 2 3 2 0 0 2 2 0 3 2 0 0 0 0 2 3 0 4 0 0 0 3 0 2 0 2 3 3 3 2 0 3 2 3 0 2 2 3 0 2 0 2 3 3 2 2 0 0 3 3 0 2 2 0 2 2 2 0 4 0 0 3 0 0 3 2 3 3 4 2 2 3 2 2 0 3 0 0 3 0 0 2 3 0 2 2 2 2 2 3 2 2 4 2 0 3 0 2 2 4 2 2 0 0 3 0 2 2 0 0 2 3 0 3 0 5 0 2 3 0 4 0 0 3 3 0 0 2 2 3 ...
result:
ok 50000 lines