QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#516786 | #4401. Prize | hotboy2703 | 51 | 1842ms | 401776kb | C++14 | 2.8kb | 2024-08-12 21:40:54 | 2024-08-12 21:40:54 |
Judging History
answer
#include<bits/stdc++.h>
using ll = int;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
const ll MAXN = 1e6+100;
const ll MAXK = 20;
ll n,k,q,t;
struct tree{
vector <ll> g[MAXN];
ll depth[MAXN];
ll sp[MAXN][MAXK];
vector <pll> adj[MAXN];
ll dp[MAXN];
vector <ll> choose;
ll in[MAXN],timeDFS;
void dfs(ll u,ll p){
sp[u][0] = p;
in[u] = ++timeDFS;
for (ll j = 1;j < MAXK;j ++){
sp[u][j] = sp[sp[u][j-1]][j-1];
}
depth[u] = depth[p]+1;
choose.push_back(u);
for (auto v:g[u]){
if (v==p)continue;
dfs(v,u);
}
}
ll lca(ll u,ll v){
if (depth[u] > depth[v])swap(u,v);
for (ll j = MAXK-1;j >= 0;j --){
if (depth[sp[v][j]] >= depth[u])v = sp[v][j];
}
if (u==v)return u;
for (ll j = MAXK-1;j >= 0;j--){
if (sp[v][j] != sp[u][j])u = sp[u][j],v = sp[v][j];
}
return sp[u][0];
}
ll root=-1;
void add(ll u,ll v,ll wu,ll wv){
ll LCA = lca(u,v);
if (root==-1||depth[LCA]<depth[root])root=LCA;
adj[LCA].push_back(MP(u,wu));
adj[u].push_back(MP(LCA,wu));
adj[LCA].push_back(MP(v,wv));
adj[v].push_back(MP(LCA,wv));
}
void solve(){
// for (ll i = 1;i <= n;i ++){
// if (dp[i] == 0){
queue <ll> q;
q.push(root);
while (!q.empty()){
ll u = q.front();
q.pop();
for (auto [v,w]:adj[u]){
if (v != u && dp[v] == 0){
dp[v] = dp[u] + (depth[u] > depth[v] ? -1 : + 1) * w;
q.push(v);
}
}
}
// }
// }
}
ll query(ll u,ll v){
ll LCA = lca(u,v);
return dp[u] + dp[v] - dp[LCA]*2;
}
} a1,a2;
int main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);
cin>>n>>k>>q>>t;
ll r1,r2;
for (ll i = 1;i <= n;i ++){
ll x;
cin>>x;
if (x!=-1){
a1.g[x].push_back(i);
a1.g[i].push_back(x);
}
else r1 = i;
}
for (ll i = 1;i <= n;i ++){
ll x;
cin>>x;
if (x!=-1){
a2.g[x].push_back(i);
a2.g[i].push_back(x);
}
else r2 = i;
}
a1.dfs(r1,r1);
a2.dfs(r2,r2);
vector <ll> c = a1.choose;
c.resize(k);
sort(c.begin(),c.end(),[](ll x,ll y){return a2.in[x] < a2.in[y];});
for (auto x:c)cout<<x<<' ';
cout<<'\n';
for (ll j = 0;j + 1 < sz(c);j ++)cout<<"? "<<c[j]<<' '<<c[j+1]<<'\n';
// for (ll j = k;j <= q;j++)cout<<"? "<<1<<' '<<1<<'\n';
cout<<'!'<<endl;
for (ll j = 0;j + 1 < sz(c);j ++){
ll u1,v1,u2,v2;
cin>>u1>>v1>>u2>>v2;
a1.add(c[j],c[j+1],u1,v1);
a2.add(c[j],c[j+1],u2,v2);
}
// return 0;
a1.solve(),a2.solve();
// return 0;
vector <pll> ans;
while (t--){
ll x,y;
cin>>x>>y;
ans.push_back(MP(a1.query(x,y),a2.query(x,y)));
// cout<<a1.query(x,y)<<' '<<a2.query(x,y)<<'\n';
}
for (auto x:ans)cout<<x.fi<<' '<<x.se<<'\n';
cout.flush();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 844ms
memory: 254072kb
input:
500000 64682 64681 100000 46115 470589 209303 2979 473162 343535 79503 299539 404621 102085 237721 279170 392890 165201 441593 456314 218991 358478 86614 410800 159785 169761 95368 285837 297549 370283 378974 26449 444381 39320 149913 404523 144109 174828 263837 49847 468694 478535 152644 216598 301...
output:
422989 414496 290928 388223 160563 301045 470257 259625 222733 231286 345214 169817 435263 277447 386014 210139 455433 225855 264772 199736 355788 288506 233893 146148 454958 267562 498596 183745 352665 151125 266374 43142 9414 204593 212097 311775 25324 300764 6643 94847 396968 428563 311355 255767...
result:
ok good job!
Test #2:
score: 10
Accepted
time: 891ms
memory: 255992kb
input:
500000 90967 90966 100000 122547 312039 290084 118442 352297 175176 294396 496975 127062 90539 132654 408480 493670 419897 53432 141795 264165 60368 473480 5634 253119 64236 85346 422987 28583 262389 111931 271291 13577 415079 132797 256502 76402 265607 11274 289667 398726 32021 302401 410650 369760...
output:
3090 193269 3028 186608 498475 64618 82114 231445 7541 329983 134623 235591 70401 18906 403427 280451 146897 355174 160090 144279 193430 332022 488244 228900 80781 84465 218682 27818 6035 368489 155673 440755 443926 241570 193717 143661 374105 56616 323329 95909 337798 20531 236329 28564 437244 4969...
result:
ok good job!
Test #3:
score: 10
Accepted
time: 702ms
memory: 237536kb
input:
500000 68287 68286 100000 273928 229768 65518 144983 311611 494773 489379 439644 467893 456131 430188 247387 485565 272285 474827 476962 338340 365804 344570 390867 390170 456217 43185 447057 385874 305750 107742 230530 259907 252254 280920 16831 45761 185191 117450 55891 175190 255615 35904 14855 2...
output:
242387 146602 106115 32426 8390 3821 314935 201979 171459 413397 469146 119187 74265 167902 479051 182695 260054 235048 135315 280891 13044 240704 209304 211564 188960 481631 289686 273785 175837 385737 204887 288861 330677 315423 120726 278204 129910 396267 322633 472675 325914 329277 67326 391455 ...
result:
ok good job!
Test #4:
score: 10
Accepted
time: 664ms
memory: 238216kb
input:
500000 63976 63975 100000 230132 63748 303785 13497 431672 370351 360004 412191 378555 409703 485802 218204 475692 27602 220794 398856 89157 166559 116145 350738 277404 196706 40307 118602 171802 378360 389092 485168 224465 383516 33147 322617 254917 274019 57283 272241 216098 421952 489927 75641 40...
output:
210552 1449 40773 30337 3831 195031 251118 21848 332855 402436 374839 357357 42119 382885 377328 13863 386544 201759 32946 323963 484564 215037 277370 472684 81309 484227 89315 381707 431727 439267 216824 485515 421976 411697 230680 43213 25204 68073 30255 143879 164080 135142 441489 282767 310382 1...
result:
ok good job!
Test #5:
score: 10
Accepted
time: 701ms
memory: 238992kb
input:
500000 87673 87672 100000 151599 456749 347511 703 348209 260440 488627 416030 419890 408089 83617 120781 133411 374231 460689 211838 137587 252914 392401 321583 55161 335205 334340 4527 14086 142229 197076 17695 262896 258702 273353 51181 10968 366799 324067 299421 281975 7236 420627 92324 299845 1...
output:
51300 4033 3297 46811 80464 284515 347374 116368 204675 12242 236061 42585 91081 312035 285728 234206 326918 231575 193431 385908 123360 219570 237308 488275 146973 278867 303046 17686 461933 83949 100486 65040 253090 278869 342370 141292 167787 205320 41653 29945 83893 40950 348576 412681 220300 26...
result:
ok good job!
Test #6:
score: 10
Accepted
time: 810ms
memory: 239888kb
input:
500000 77912 77911 100000 270576 129318 366297 25873 179787 473782 221947 331327 209469 412992 410608 286179 37554 355546 297085 420463 496948 223036 122019 151250 478469 468136 19073 318549 398897 364415 23730 407160 26064 436939 30150 336421 375149 131841 58480 259944 117641 414831 64311 336164 31...
output:
210887 26617 47747 209286 31977 243665 65697 394458 66936 330203 111706 400826 188117 490312 451749 377213 451432 482110 450513 372367 243217 17878 326862 79427 343913 203244 140881 256494 329204 164961 461047 338802 166743 393825 25540 420037 374407 50003 96053 427346 365280 191816 338726 463407 32...
result:
ok good job!
Test #7:
score: 10
Accepted
time: 832ms
memory: 240592kb
input:
500000 77688 77687 100000 433011 472346 395389 187114 436024 138403 189990 398859 136147 195283 331183 46789 19828 335128 387768 442181 65556 72327 318927 462834 421288 227912 37067 387794 145879 258896 185861 356020 202881 490952 443694 95413 137215 137239 112863 481338 167802 304239 309781 391976 ...
output:
176419 131882 35390 373863 172713 204978 297105 474574 443479 326538 390969 34874 492305 157831 85371 217598 310810 104348 344506 18218 34919 284048 191391 375157 93215 437374 179027 95313 246201 105486 90705 261692 432138 60063 214041 101698 415529 126781 367122 27413 85730 36224 346513 104818 2238...
result:
ok good job!
Test #8:
score: 10
Accepted
time: 807ms
memory: 239428kb
input:
500000 70973 70972 100000 449081 8094 7358 89457 426121 454508 470543 485236 63347 441977 422774 88672 243638 499709 170209 157788 229166 106888 228931 289706 435222 496384 381579 323479 499140 1511 385050 44171 413854 248273 352221 305112 24289 277461 391744 395003 85800 396455 355110 186446 285096...
output:
449195 92100 139432 131622 170991 324408 396138 18454 365411 494280 359470 62857 516 49116 212775 228269 406044 238351 73730 344036 164637 142035 62522 287306 191612 27113 107127 151520 273425 3029 266766 489355 250496 60335 369915 212496 230914 324800 64090 294847 116290 472262 346162 136322 249997...
result:
ok good job!
Test #9:
score: 10
Accepted
time: 697ms
memory: 237448kb
input:
500000 66403 66402 100000 297237 432967 138046 88503 315699 372893 55309 335404 127581 165919 247543 254268 285147 289728 275281 44427 94393 302830 489861 429097 425153 11083 439096 414157 386411 152968 394984 46119 149177 369378 413029 198215 134317 366218 281170 465540 39702 367778 247925 64320 86...
output:
294428 15990 60747 1844 173342 476686 180822 429820 298329 356039 58547 290254 180015 476506 20120 265956 172302 27153 59287 30817 110197 441521 428010 2003 112355 265905 198312 129358 442298 120472 138884 373998 58266 256425 7274 137614 43114 65060 393472 137647 293565 81701 495260 317778 230822 47...
result:
ok good job!
Test #10:
score: 10
Accepted
time: 696ms
memory: 238988kb
input:
500000 82328 82327 100000 280281 366446 183709 14447 442815 440473 121531 103568 472324 479656 337467 424742 474404 340302 269686 457628 230012 484228 422877 10759 156759 66102 130428 307888 123685 460634 235321 98667 93133 489886 479420 34961 352500 322001 129001 121871 135775 235639 100221 221760 ...
output:
185494 36690 87374 138798 36564 181594 428424 260437 178882 134288 146942 90320 210326 241671 445549 121178 164319 184591 354583 355428 247773 281684 307841 387907 97435 102464 184979 164216 317633 56960 295193 191071 295961 328549 299162 27136 188202 118130 161902 236258 147998 155971 322975 474055...
result:
ok good job!
Test #11:
score: 10
Accepted
time: 649ms
memory: 235552kb
input:
500000 53948 53947 100000 287984 258934 272973 481182 131565 217198 34714 463056 337977 495727 310042 26372 320480 231799 249741 340990 365501 267377 460708 248843 285777 172137 492784 201463 213559 259528 461602 235849 398717 25475 241699 451061 188952 251790 83551 169967 335575 209367 55705 6381 2...
output:
490646 30912 58228 256224 419416 179276 226624 297156 434671 224297 66900 102019 206352 345445 170824 216398 382142 38139 295276 461808 479814 117039 338283 434145 494560 141370 72417 19374 27632 289877 24100 185985 333545 136905 137035 102602 147548 27797 299360 304944 475001 306860 73631 185755 27...
result:
ok good job!
Test #12:
score: 10
Accepted
time: 698ms
memory: 238568kb
input:
500000 77935 77934 100000 38748 422564 39441 105430 38474 225464 237519 121832 72613 477531 321661 29181 307418 314049 120252 261006 88761 17726 492112 460837 55199 354114 417097 133271 231933 436973 110894 478550 291976 50101 38774 316091 306160 121826 315769 361823 82990 188508 124574 13093 235123...
output:
423149 92225 16389 129241 166449 184539 134974 114717 355886 329721 379424 292962 421117 497443 381527 149162 408 10702 212632 50138 317213 372008 378849 113411 195237 172507 239020 420304 489080 360466 438166 227686 419986 209153 382570 15084 218300 418265 483901 215816 378626 452355 214360 491276 ...
result:
ok good job!
Subtask #2:
score: 0
Time Limit Exceeded
Test #13:
score: 25
Accepted
time: 990ms
memory: 256904kb
input:
500000 88721 177440 100000 30974 23891 211201 125199 180489 387190 218020 498838 230147 307989 484136 257785 353027 304420 311738 169842 334090 486070 126212 328609 174959 368840 238722 418092 488389 226349 427271 457322 332454 12958 197530 264474 355717 482774 221286 282148 216441 266659 213750 628...
output:
299348 225578 286701 388703 273711 466172 478011 490391 462013 126494 92677 182472 13812 107732 303666 361862 256289 91025 389690 156797 268792 434419 208299 409874 319842 64913 385537 136511 498213 255392 208598 45196 97386 482069 290480 370649 225780 380585 84550 485237 301855 494683 414740 107270...
result:
ok good job!
Test #14:
score: 25
Accepted
time: 886ms
memory: 254936kb
input:
500000 50267 100532 100000 68723 142685 445548 215087 478634 201362 177405 373123 227456 161487 276716 452818 230715 466238 250886 368974 77152 493722 129115 154402 319190 170867 27898 338290 170229 428001 62611 19188 164329 435154 128 358453 137653 430592 160391 407392 125236 320137 27945 393135 17...
output:
180276 246334 495583 402629 160081 135829 437502 411046 380530 139431 365266 373213 304147 83868 82333 429663 60973 379653 172399 163454 32708 375362 151036 335442 305087 243402 252686 172089 94334 222818 22129 288097 54119 315516 305714 257805 486465 169334 213035 447566 446068 161042 183900 97933 ...
result:
ok good job!
Test #15:
score: 25
Accepted
time: 706ms
memory: 235976kb
input:
500000 67604 135206 100000 269046 235003 144646 314602 323547 204450 484229 26672 78499 602 110738 117079 125630 408912 188317 256853 71590 365703 370008 194267 342683 400737 369194 127912 96314 269751 219125 431887 398790 200053 279314 365797 187505 75025 48264 492515 387506 13267 80948 378737 1106...
output:
410957 102640 57040 447297 448703 24334 254889 77275 293399 345300 471259 482786 199969 188760 419540 436680 217376 127367 321519 11476 40719 5121 430565 22593 274317 171984 466284 283845 312405 479173 72277 352329 333338 297543 48229 286138 161512 309021 279771 261137 13943 32976 177635 383998 2832...
result:
ok good job!
Test #16:
score: 25
Accepted
time: 780ms
memory: 239544kb
input:
500000 90109 180216 100000 153893 273609 184853 157428 466683 457867 343783 259618 87262 260826 466902 41972 482221 496695 293976 300490 455874 320279 314574 128316 280220 2566 383716 351629 219577 29212 26631 73182 458601 318651 105942 60715 392339 265615 387177 110713 319395 336826 483543 70790 36...
output:
300632 186862 324036 365377 368911 267203 479391 209524 283692 437379 74405 17184 464848 238979 333414 85801 324166 458631 160861 224370 158956 177477 263102 432052 236921 235894 22925 59509 243755 83527 324556 204784 449634 474971 159100 317353 446070 326458 434304 334660 64746 493304 195588 283249...
result:
ok good job!
Test #17:
score: 0
Time Limit Exceeded
input:
500000 74321 148640 100000 477030 412534 57969 357009 116485 327483 437765 67781 471780 418080 308252 138279 338053 95055 275789 97204 386829 122048 57181 436136 222481 395950 352928 73438 250800 184259 16097 398913 456107 105407 39764 116186 80552 65160 316601 284871 313136 414498 414938 343247 310...
output:
149543 6947 287046 193333 354364 272473 238091 464710 330607 269800 72913 92958 130042 39030 217396 329535 415663 119741 127152 343889 365903 480591 227214 446907 204663 392299 146039 339117 433146 359596 450547 177435 382843 382902 95004 462751 174027 351949 44929 279279 413504 234625 260645 432200...
result:
Subtask #3:
score: 19
Accepted
Test #25:
score: 19
Accepted
time: 627ms
memory: 246708kb
input:
500000 200 199 40000 76296 130139 291501 292412 139543 433345 372726 451574 18315 465578 324564 477223 237354 81532 65170 465332 342130 9670 193303 193680 129668 149532 268907 89969 398275 356210 324593 433492 482232 466692 135343 433758 102545 287283 432859 351864 305769 489532 101532 450535 295762...
output:
12225 329473 124294 112780 478338 445039 249189 32330 65783 179054 497476 452979 319006 30813 48206 427935 466790 486377 109196 200837 164218 45188 487722 282259 229713 367076 188057 187010 232559 151913 348461 116954 20242 322713 185020 157495 443679 326708 325415 391214 266949 457474 3735 299220 2...
result:
ok good job!
Test #26:
score: 19
Accepted
time: 648ms
memory: 246748kb
input:
500000 200 199 40000 83785 150667 304961 267635 97760 385201 77226 6522 352645 72592 427133 30755 100574 359648 403948 394809 425453 115868 11287 351385 494434 245106 58157 395180 326236 277135 359592 13569 76251 45366 172378 122783 216597 466130 284420 342613 471698 380682 92490 79264 241049 54038 ...
output:
455890 309275 63656 335800 292806 9763 489623 63346 86191 446791 183068 362736 197911 107095 211424 101597 145440 202553 8696 425553 151090 60540 369501 412878 462364 222 148686 133609 158102 107714 270626 112101 244973 133381 421561 462192 28928 193698 101629 183699 205161 304190 364442 409432 4207...
result:
ok good job!
Test #27:
score: 19
Accepted
time: 509ms
memory: 231360kb
input:
500000 200 199 40000 94863 498513 460682 411416 360517 309831 253717 325019 496632 255803 130770 289206 181204 74729 481723 293737 94126 307214 342974 448321 17084 433126 387809 279606 251781 65795 125269 129465 433572 219622 11806 179248 367117 84640 114067 122590 4140 116015 77759 392439 408930 10...
output:
169886 390279 368972 148339 120867 255654 425227 466391 364651 290210 320026 437371 497635 41842 386320 65024 14065 233867 357207 420188 469081 258948 114753 140059 323833 246889 80317 274110 254320 97822 456153 178210 110359 256453 402585 495349 408878 101879 228544 89744 24166 280870 36284 297613 ...
result:
ok good job!
Test #28:
score: 19
Accepted
time: 489ms
memory: 228432kb
input:
500000 200 199 40000 460896 356428 214577 150748 16877 1635 258267 370689 262538 369939 466845 415822 304104 329494 6035 489031 48344 181107 61121 4048 156120 273134 234110 418870 101454 330401 45460 74853 175589 44170 192108 214802 482345 120910 76381 307448 204387 170471 187255 20694 494550 351800...
output:
277039 115997 135661 340482 424194 362351 238065 40626 417051 160657 171388 57613 108700 246994 205177 116589 425956 299352 204060 47845 12303 427799 313371 213726 108063 256879 425090 241060 124069 278039 130455 319552 482651 304234 369328 397486 143964 457763 15347 490303 199799 430269 173509 3508...
result:
ok good job!
Test #29:
score: 19
Accepted
time: 508ms
memory: 229180kb
input:
500000 200 199 40000 472275 149661 377034 488618 186507 171592 345983 124571 76807 5855 300138 80553 340257 185587 378146 311401 334561 194922 182638 104826 420776 448537 393232 195734 347470 219413 82586 185915 58528 404731 329285 300479 342445 115864 230618 360114 281628 86760 203158 212935 376440...
output:
387467 152541 364422 208450 209285 127799 356081 340071 321812 198782 352083 464422 127137 209028 359779 404982 202331 192467 458138 310574 373023 129373 317155 12845 466062 44555 28678 28626 221638 301663 109762 367535 417850 68250 269331 246522 88635 403663 139196 48164 256643 51501 372675 217479 ...
result:
ok good job!
Test #30:
score: 19
Accepted
time: 575ms
memory: 234536kb
input:
500000 200 199 40000 457235 436089 312892 490957 247950 207946 50653 437012 325088 141386 319878 207087 398253 383132 11996 402164 409233 443227 294400 242006 327126 10129 244769 232885 165818 291514 332036 352883 406737 63191 380159 208131 327008 61194 18237 223687 413010 160943 426911 162568 18875...
output:
351937 37377 372225 280018 217830 173527 464515 359539 288089 422572 148241 221892 324681 15183 271825 46297 331567 35725 156748 365448 72460 109652 109480 218423 117360 116283 131115 315499 27540 103384 40223 471908 316103 218129 335318 374394 206279 12323 250163 256183 81810 121002 74556 428847 13...
result:
ok good job!
Test #31:
score: 19
Accepted
time: 578ms
memory: 238280kb
input:
500000 200 199 40000 498222 451076 484997 74171 344510 119552 181399 378715 468521 103237 143923 10760 103036 353626 331913 232159 181090 14984 85005 467731 200014 74750 304897 488094 80862 428792 303440 325833 70112 301252 111208 109820 23216 97480 361786 424164 357979 22040 249278 329701 472798 13...
output:
304506 92502 440095 153916 182886 113063 356177 224978 397399 272019 276419 37017 287424 262919 363405 100050 376862 101641 118562 64749 171779 69401 347823 308588 393886 202564 472619 8577 90310 338444 142372 226857 359860 29892 235122 139187 280041 51504 243324 117455 352380 351579 318234 133514 4...
result:
ok good job!
Test #32:
score: 19
Accepted
time: 591ms
memory: 233968kb
input:
500000 200 199 40000 235229 335906 185851 155252 476682 68595 44502 499901 403010 120212 365527 365904 165512 445297 44401 416812 282314 301556 484290 469265 250037 184042 387456 226812 371932 410610 263086 279108 442354 371814 37100 77190 202799 118817 250469 478086 307786 11617 132836 304380 25170...
output:
57134 290894 76375 74473 92053 483873 238022 165420 309688 493051 112270 99033 287837 403445 158285 115778 411774 307563 94549 64907 164009 240655 312104 276130 28480 80583 33120 288913 120027 306267 68172 234899 483026 96491 74615 369615 121606 353460 464630 305703 52210 333664 359074 48083 103393 ...
result:
ok good job!
Test #33:
score: 19
Accepted
time: 538ms
memory: 234316kb
input:
500000 200 199 40000 27113 326978 70968 474916 390195 217639 467929 292659 58323 454399 169213 185253 114409 287912 251420 281315 94695 326310 237316 424237 79688 285918 43312 65978 450176 255930 425562 242907 198847 77977 135410 122795 349710 416624 428899 314932 135513 464911 286182 28508 268649 1...
output:
265540 144381 178255 455923 59217 477356 144515 330549 315402 48896 279597 83181 342077 482783 41167 225635 470507 306946 219413 339271 242489 325446 435683 446809 99685 159220 210793 471494 116083 19445 135965 313461 74267 8039 59292 29209 383248 278196 195472 375461 305637 142674 294751 436589 429...
result:
ok good job!
Test #34:
score: 19
Accepted
time: 559ms
memory: 236480kb
input:
500000 200 199 40000 158367 3349 98725 462635 71709 384166 328253 132679 334131 433401 352051 9045 188775 366068 218093 90403 193264 359869 432442 263881 154277 470908 470355 200679 36628 399310 359036 163322 404722 42891 12614 147023 421373 479199 71619 182994 443724 120532 217367 134309 221302 310...
output:
8170 148756 120030 472694 9230 81525 293615 267439 358587 309645 1642 487967 367466 43463 42484 423580 234987 462296 190140 76388 260221 371851 79469 421340 116286 479215 42126 94856 376614 69325 333748 418718 114721 297555 189369 306380 233233 393200 20890 27258 227095 22054 223421 258927 272981 20...
result:
ok good job!
Test #35:
score: 19
Accepted
time: 578ms
memory: 234204kb
input:
500000 200 199 40000 487441 36354 395955 6882 385179 368092 7896 377902 329818 287628 224290 27427 439352 326593 43030 180557 361665 163 8128 233496 22632 367138 126510 64436 351877 190302 145137 17783 209795 411209 255585 72497 161599 407307 216969 128706 67358 261184 268088 304573 63115 386332 827...
output:
401131 407598 154584 234346 364301 40443 112209 187505 395014 132382 71246 449432 202951 369639 106942 406004 269534 20475 119751 279336 494510 425126 40763 480106 226788 484854 226918 147073 238578 7515 146332 496319 375614 441312 351912 244910 251468 149614 485685 436202 89871 183317 249086 60145 ...
result:
ok good job!
Test #36:
score: 19
Accepted
time: 556ms
memory: 234620kb
input:
500000 200 199 40000 234051 59729 19849 414190 183195 238559 189881 256369 97803 379735 363604 391055 490274 186114 46653 230044 14075 437112 279313 141334 478372 146753 310018 305921 464449 475813 132149 290804 21707 51493 249658 15019 151386 494305 468781 444714 318658 179510 283604 351846 110675 ...
output:
322686 448278 410090 357210 193698 98888 410963 95760 210926 125554 415948 214562 405005 43563 273856 105089 490855 192459 51747 444712 348730 153465 276012 88212 339746 159682 199086 323890 462351 227840 14478 252767 396521 329727 224253 268698 348696 155606 312473 325328 458413 297897 387671 36161...
result:
ok good job!
Subtask #4:
score: 22
Accepted
Test #37:
score: 22
Accepted
time: 1484ms
memory: 391196kb
input:
1000000 1000 999 100000 678746 439069 32542 85937 936926 284219 461661 203235 533462 940676 230275 621140 780674 254931 562355 229273 201341 493976 358955 963527 880412 91220 474599 160086 698841 591551 718276 844558 39859 765917 34722 401724 219774 443004 682244 545401 968419 968020 354030 411187 1...
output:
927453 737189 653885 840772 346403 780854 103601 49131 439139 486132 820231 177271 826206 982104 499097 409243 194435 293457 172618 662161 236859 473531 81188 533335 712368 462084 777243 239386 911529 829354 62098 492333 390487 523069 358162 163042 451543 653539 717744 885154 584533 11086 661366 952...
result:
ok good job!
Test #38:
score: 22
Accepted
time: 1479ms
memory: 391196kb
input:
1000000 1000 999 100000 530144 36744 762893 712555 181981 816257 634992 419372 362279 817260 80801 697008 163211 900947 207310 862766 871091 388529 304808 574011 609949 509094 682125 781230 431445 517909 578411 288003 874415 410542 327673 607230 278208 956997 60166 842448 708661 562761 996349 382922...
output:
70930 162711 104847 600658 547594 219142 447597 811056 140247 502224 659605 421892 389493 152949 636421 692108 137214 372169 804489 399568 586198 152111 43257 899797 878142 278025 996438 364577 750352 580921 589621 139136 802259 100210 987920 563289 985356 224651 422771 630597 972354 915562 97459 56...
result:
ok good job!
Test #39:
score: 22
Accepted
time: 1184ms
memory: 353976kb
input:
1000000 1000 999 100000 184414 849676 938006 927343 390133 327580 229110 507237 712311 8816 414520 114671 637641 82050 586607 523821 775429 139792 129360 175687 202474 801377 53523 281419 268534 488983 371227 294280 754555 448802 474939 391153 68307 762784 972243 245396 471656 982894 891252 945526 5...
output:
663226 751559 917046 696399 375962 818226 289125 610609 777258 170016 838990 153880 821864 924159 250899 779794 364016 382500 98015 617080 441876 395412 502839 699761 164511 226542 375771 737883 860066 552479 483256 421931 673013 567303 501290 679968 893276 299396 376228 927319 24516 20128 319113 93...
result:
ok good job!
Test #40:
score: 22
Accepted
time: 1207ms
memory: 354128kb
input:
1000000 1000 999 100000 279950 249721 597292 449885 16559 173928 771422 461514 392390 935006 401814 270115 877076 38286 665465 238399 632929 179581 685305 910549 211998 608701 352060 872741 888320 701449 144650 551823 899287 53420 994085 608934 941044 730655 818001 379877 176374 592364 165476 704855...
output:
526846 80277 501716 139556 531000 926968 995445 370694 139434 712752 275837 700914 51000 299826 295462 832447 848302 82220 760903 777594 736010 64390 476316 197749 395626 99315 517685 554718 643827 174974 346331 713321 314920 118095 573580 360301 163334 599068 51485 778505 845218 579583 508091 41643...
result:
ok good job!
Test #41:
score: 22
Accepted
time: 1137ms
memory: 353792kb
input:
1000000 1000 999 100000 20291 14699 561360 480484 286821 851537 642046 340254 362763 85475 567413 791788 145352 893579 253840 568256 281056 600506 834619 722257 570033 739505 158527 142792 475867 834583 85573 692242 107763 238427 749609 945275 238413 468714 75532 903433 452471 189579 134021 196949 2...
output:
439784 544187 10081 932090 115605 537573 545373 569210 13399 392052 841018 813809 514846 833387 955880 322204 373343 839850 496260 6959 662534 164911 205369 359323 929102 990177 938347 571103 811501 431645 791670 852177 865887 391715 487695 566108 729076 934889 77242 306852 838412 533464 958799 2763...
result:
ok good job!
Test #42:
score: 22
Accepted
time: 1421ms
memory: 359248kb
input:
1000000 1000 999 100000 79586 680985 105418 485822 250996 367398 927624 781485 911744 133593 352104 588258 914821 421528 538901 315958 275633 856427 5509 935195 913751 92920 619111 848814 663965 45219 344279 165968 865619 154854 900710 774023 872807 340764 497215 631438 911663 879056 918477 890010 3...
output:
45622 880700 700254 168883 404042 302538 746532 780065 305715 712486 246262 208537 703235 604066 807355 744570 362073 551390 599323 224629 728976 229663 519432 806197 723320 190988 961301 904451 658317 119601 191256 519118 870872 300299 424079 333661 630212 509268 267712 617157 656064 658492 19750 2...
result:
ok good job!
Test #43:
score: 22
Accepted
time: 1395ms
memory: 359508kb
input:
1000000 1000 999 100000 864268 381722 137834 585983 418961 493735 111546 74594 3531 508504 383125 609419 708077 928352 762197 141167 174341 418962 107812 631708 84967 770802 568509 276991 376328 909246 85244 453348 203444 298108 478742 824330 149959 297025 840543 296938 691263 894733 491791 319919 8...
output:
163828 718689 436365 457207 889329 332482 451049 776073 79234 828674 994550 164088 675956 884691 808369 790774 27275 784232 328601 100623 233827 577315 566466 41813 26518 775412 470028 907955 464127 35641 115108 299320 885636 78773 819218 17269 685182 250373 511069 401919 346542 587806 900274 486388...
result:
ok good job!
Test #44:
score: 22
Accepted
time: 1398ms
memory: 359188kb
input:
1000000 1000 999 100000 845169 885017 493118 865999 3330 999692 653381 608408 419452 799529 98306 295418 755923 442503 85146 52116 980435 452773 633069 998249 788034 527181 418057 380217 158464 23015 364569 275325 675030 381121 889352 891866 203541 14657 69958 428476 4927 853670 908949 664221 936648...
output:
740055 890594 144027 442434 776751 726345 247487 86730 301980 790860 368163 131042 593268 607491 852059 414557 294928 373362 875411 383421 432698 226981 782316 194212 202827 554926 725764 655320 971471 124841 507499 218405 314424 829007 529823 227435 669473 170793 96323 284730 844475 581582 251447 4...
result:
ok good job!
Test #45:
score: 22
Accepted
time: 1270ms
memory: 360416kb
input:
1000000 1000 999 100000 582602 618937 427880 217239 896256 608317 42018 91716 145269 277504 94008 601157 503365 892936 294525 477654 286441 721652 14541 805171 315688 615193 950960 232416 430226 299443 690527 317106 303199 277200 283069 268869 650167 725195 788623 817992 647261 671722 426903 453937 ...
output:
607360 577128 97216 807653 212580 256273 512125 310872 526976 747432 749980 226046 172523 411773 788302 211862 370424 169289 183950 22592 440558 294211 550699 862689 797963 237964 275643 708285 560832 429578 50435 552608 727997 573647 720724 244293 491451 834172 944370 39667 859199 94435 99679 53989...
result:
ok good job!
Test #46:
score: 22
Accepted
time: 1295ms
memory: 360296kb
input:
1000000 1000 999 100000 761086 125560 807519 496861 197173 671162 286468 361527 420830 337089 99902 928320 527383 162932 540385 255275 952224 668471 897966 186547 575192 315130 399856 441499 876295 462690 556218 167574 711101 146911 914260 296451 432034 722939 27102 687771 200204 636114 525983 59197...
output:
893407 690920 750769 525612 209678 759832 389007 189285 24515 801755 785543 528530 721991 217281 784294 299904 412175 858735 122341 757082 740702 315595 225770 374344 643508 677672 621477 152369 250727 126837 444059 568031 786820 716703 738971 375270 851474 50518 938934 173418 597621 46926 890052 81...
result:
ok good job!
Test #47:
score: 22
Accepted
time: 1315ms
memory: 360220kb
input:
1000000 1000 999 100000 700422 705984 742655 297368 991331 273447 971924 235042 288410 226105 751213 71757 552545 234328 777224 460184 747354 483278 77275 960232 145343 677496 979573 598317 294693 762557 214101 155814 368037 345816 214266 272277 6667 461234 109578 330628 355557 16281 696921 633114 6...
output:
515392 988130 667484 201431 466307 241543 429916 4025 813247 244196 113915 753204 702425 221352 84260 6163 24858 533550 650234 84255 952669 765919 564802 409322 585789 828694 251180 865743 149680 499169 52811 933959 237562 711812 857154 47215 863979 836063 360217 667695 963646 594185 834546 326422 1...
result:
ok good job!
Test #48:
score: 22
Accepted
time: 1328ms
memory: 361008kb
input:
1000000 1000 999 100000 294979 912636 954626 984835 432393 676651 323592 496950 442003 287176 988897 310588 517194 868410 42913 165122 231552 13998 103334 502710 396538 590023 630061 530055 980426 628250 446184 451072 276133 424200 328584 26687 392134 766381 197139 174221 564083 149136 481705 457343...
output:
661968 229261 382766 183556 787068 596192 922320 559617 240427 901516 676085 48315 159215 336433 122850 736114 540875 351271 48427 355726 6321 420838 647589 878527 726128 990014 141281 836075 224941 821350 293392 822017 488511 10591 416590 23180 106470 428076 870942 69114 28574 894726 609417 688305 ...
result:
ok good job!
Subtask #5:
score: 0
Time Limit Exceeded
Dependency #4:
100%
Accepted
Test #49:
score: 24
Accepted
time: 1842ms
memory: 401776kb
input:
1000000 91074 91073 100000 844855 360256 604500 520288 3402 603913 199722 732526 574997 429775 182518 190073 386932 693624 254661 333433 557929 350362 247817 201441 960948 519977 461212 493412 852908 455639 732827 432452 320916 223796 413293 969300 617038 438432 2369 51283 908991 374139 410798 19612...
output:
104349 170744 322298 943785 796710 500874 79937 976772 191057 27689 906009 603418 442795 561154 796064 292228 504787 249824 525843 435036 271618 183442 461251 6332 765553 582250 226179 860734 445334 729051 457570 772087 147634 119269 85940 899087 838934 714547 249430 419834 488759 535606 70064 74100...
result:
ok good job!
Test #50:
score: 24
Accepted
time: 1809ms
memory: 401204kb
input:
1000000 85406 85405 100000 243967 952129 483179 427670 241063 673465 936850 819488 932267 432087 168570 75516 427761 708350 579841 56944 327580 291932 619630 977053 424711 862203 360360 723933 64552 550800 399697 549936 425473 413499 431310 248361 149311 199196 247552 227202 676100 694069 347994 988...
output:
600691 665700 394186 920033 67110 282228 422563 424839 65617 886450 197532 463926 711771 581926 743376 860065 363944 619369 548813 448810 333494 514122 109376 269392 289634 194364 244306 322851 208595 223144 694693 3079 572346 25709 765912 66723 337394 544324 945673 108504 78758 851948 167958 84801 ...
result:
ok good job!
Test #51:
score: 24
Accepted
time: 1407ms
memory: 361244kb
input:
1000000 62028 62027 100000 354774 944572 228278 449941 359325 57969 43031 616490 898916 61312 768136 892022 42765 227563 373737 241400 671641 155600 137082 803792 95473 30579 438130 496747 204238 57940 100124 47370 141803 745731 687568 952816 518284 677981 803613 28392 918299 517226 69867 69501 8590...
output:
492526 940254 808252 465165 535599 597162 956379 956362 843980 4971 976977 766455 454900 204607 443087 453035 365855 293909 818138 956229 816677 337216 492934 867721 46959 499916 573712 945784 987204 286218 125416 913323 904187 693753 772700 759036 368412 613344 738546 952849 344787 740627 150772 33...
result:
ok good job!
Test #52:
score: 0
Time Limit Exceeded
input:
1000000 97415 97414 100000 453981 477203 689925 857434 241949 91494 993077 34954 605245 874902 893112 881129 576016 404784 870963 602740 1572 569897 624684 792962 189914 558522 191463 49120 326617 360379 162970 903046 277880 985508 419832 756246 978897 958038 74713 370260 67182 710992 829080 535448 ...
output:
629550 622879 782360 286129 57840 267343 338393 528278 948466 747547 677958 894770 348991 547550 996983 975769 110403 863504 107828 198401 667313 559117 459221 307718 415496 172135 640107 388852 65400 494732 435148 834610 3029 367575 638201 626177 109050 334373 636129 333926 915570 614194 732380 876...