QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#548200 | #8237. Sugar Sweet II | pengpeng_fudan# | AC ✓ | 239ms | 71604kb | C++23 | 2.8kb | 2024-09-05 16:21:57 | 2024-11-04 17:05:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define maxn 1000005
#define mod 1000000007
int64_t Mod(int64_t x) { return x >= mod ? x - mod : x; }
int64_t qpow(int64_t a, int64_t x) {
int64_t ans = 1;
while (x) {
if (x & 1) ans = ans * a % mod;
a = a * a % mod, x >>= 1;
}
return ans;
}
int64_t inv(int64_t a) { return qpow(a, mod - 2); }
const int inv2 = inv(2);
int a[maxn], w[maxn], fa[maxn], indeg[maxn];
int64_t f[maxn], fac[maxn], ifac[maxn];
vector<int> graph[maxn];
void solve(void) {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], graph[i].clear(), f[i] = indeg[i] = 0;
for (int i = 1; i <= n; i++) cin >> fa[i], graph[fa[i]].push_back(i), indeg[fa[i]]++;
for (int i = 1; i <= n; i++) cin >> w[i];
vector<int> lis;
queue<int> que;
for (int i = 1; i <= n; i++)
if (!indeg[i]) que.push(i);
while (!que.empty()) {
int p = que.front();
que.pop();
lis.push_back(p);
if (!--indeg[fa[p]]) que.push(fa[p]);
}
reverse(lis.begin(), lis.end());
for (int i = 1; i <= n; i++) {
if (!indeg[i]) continue;
vector<int> ring;
int tp = i;
ring.push_back(tp), tp = fa[tp], indeg[tp]--;
while (tp != i) ring.push_back(tp), tp = fa[tp], indeg[tp]--;
reverse(ring.begin(), ring.end());
if (ring.size() == 1) continue;
int m = ring.size(), p = -1;
for (int i = 0; i < m && p == -1; i++) {
int pre = (i + m - 1) % m;
if (a[ring[pre]] > a[ring[i]] || a[ring[pre]] + w[ring[pre]] <= a[ring[i]]) {
p = i;
break;
}
}
if (p == -1) continue;
if (a[fa[ring[p]]] > a[ring[p]]) f[ring[p]] = 1;
for (int i = (p + 1) % m; i != p; i = (i + 1) % m) {
int p = ring[i];
if (a[fa[p]] > a[p])
f[p] = 1;
else if (a[fa[p]] + w[fa[p]] > a[p] && f[fa[p]])
f[p] = f[fa[p]] + 1;
else
f[p] = 0;
}
}
int64_t inv2 = inv(2);
for (auto p : lis)
if (a[fa[p]] > a[p])
f[p] = 1;
else if (a[fa[p]] + w[fa[p]] > a[p] && f[fa[p]])
f[p] = f[fa[p]] + 1;
else
f[p] = 0;
for (int i = 1; i <= n; i++) cout << (a[i] + (f[i] ? ifac[f[i]] : 0) * w[i]) % mod << ' ';
cout << endl;
return;
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
fac[0] = ifac[0] = 1;
for (int i = 1; i < maxn; i++) fac[i] = fac[i - 1] * i % mod;
ifac[maxn - 1] = inv(fac[maxn - 1]);
for (int i = maxn - 2; i; i--) ifac[i] = ifac[i + 1] * (i + 1) % mod;
int _ = 1;
cin >> _;
while (_--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 11ms
memory: 30396kb
input:
4 4 2 5 5 2 4 2 1 3 3 2 1 4 3 5 4 3 1 1 1 6 6 6 3 5 4 3 2 3 1 1 2 3 5 2 1 3 2 1 5 1 1 3 4 1 3 4 2 4
output:
500000007 5 5 6 5 10 9 166666673 5 6 500000006 4 3 4 5
result:
ok 15 numbers
Test #2:
score: 0
Accepted
time: 153ms
memory: 30072kb
input:
50000 5 508432375 168140163 892620793 578579275 251380640 3 4 4 1 3 346232959 736203130 186940774 655629320 607743104 1 863886789 1 364158084 18 864679185 463975750 558804051 604216585 694033700 499417132 375390750 337590759 467353355 111206671 983760005 984444619 322277587 138763925 205122047 97736...
output:
854665334 904343293 590444253 906393935 859123744 863886789 871186919 814243920 968784984 206455474 17527050 449261413 196759729 901433117 519383814 907574792 983760005 984444619 489899014 435736558 113628626 977360756 482247153 963066959 665922935 577926775 132646723 421298438 601054667 99438820...
result:
ok 500000 numbers
Test #3:
score: 0
Accepted
time: 104ms
memory: 30304kb
input:
5000 32 770948244 768935990 679008477 140059459 126718762 172369567 60723299 139563987 671220914 149354390 157693423 281776861 412464718 869245476 446234952 827569915 294423239 672541652 309942421 252597259 603376135 207343159 409718246 366254256 59153054 589167713 171168426 802508752 545258815 7373...
output:
351791786 607445427 53351025 96277100 671164280 94237502 491532542 689573864 38427324 382704130 816373728 309284273 690430261 869245476 291526004 827569915 99656414 748890295 609504084 467918578 603376135 501064338 501009010 85120176 17055939 969361082 892391697 802508752 545258815 333168524 1165920...
result:
ok 500000 numbers
Test #4:
score: 0
Accepted
time: 116ms
memory: 30688kb
input:
500 831 941014154 653817226 737317394 548891909 650240324 784152288 337897920 919008275 807254058 243382923 935726688 583553418 88833789 750399807 577623567 595406246 982133524 532836513 286249019 780939608 102125785 501372622 567570217 761966021 24185161 261377492 548514161 60622277 424507766 53868...
output:
230438528 510098604 738011151 548891909 580268181 784152288 162823835 919008275 807254058 787780699 169718491 688535564 555077367 834193932 577623567 199204617 982133524 727940533 893934195 780939608 85179822 570950549 313144085 761966021 26675845 421401245 433344217 526647729 682184775 211847212 73...
result:
ok 500000 numbers
Test #5:
score: 0
Accepted
time: 133ms
memory: 32520kb
input:
50 15547 79925051 123631785 451773599 290189979 8044136 985464173 25844832 289071231 239507420 289791589 915514277 479789432 442504231 802244771 740816861 403881580 976651260 224945729 212313439 170590725 774102963 484364764 878553828 980521523 949147335 322115091 853616905 280879526 946658136 41530...
output:
284534137 370503506 451773599 700040615 326578027 985464173 354118840 239415089 726041909 289791589 556747412 978820837 939334538 802244771 214118527 173005433 375935904 451502781 253004725 744007077 774102963 484364764 542287768 980521523 949147335 322115091 853616905 154636248 189607066 65863811 8...
result:
ok 500000 numbers
Test #6:
score: 0
Accepted
time: 140ms
memory: 56612kb
input:
5 323943 564718673 657489855 373282330 667584659 850348020 593942770 903492853 897217447 211655411 409828915 29599937 288981803 845363118 245960658 704846394 990499066 857206811 623803672 777109873 572212135 214230853 504844223 538282312 203265013 863644873 788795254 168640248 169295455 678434394 38...
output:
204335171 290429080 749926264 271550943 90669489 593942770 395887561 897217447 1122646 649466642 138487066 705990516 34851501 408992627 704846394 990499066 593266173 831686749 216979707 572212135 604730070 581128644 538282312 915779172 863644873 788795254 107879446 16737318 389993995 484044594 99298...
result:
ok 500000 numbers
Test #7:
score: 0
Accepted
time: 171ms
memory: 64524kb
input:
1 500000 167959139 634074578 773386884 503722503 2087506 443917727 691952768 150414369 45277106 674936674 279198849 421436316 140515506 451394766 695984050 254786900 17672277 228874183 25408976 166546966 609238004 783615461 523051181 854261286 433389755 773727734 127680943 43034811 892657961 4051531...
output:
504430027 374470866 773386884 605046474 48849004 443917727 489848651 669510599 807540660 887381332 434390308 135903469 373981470 557045185 817416129 330927981 295776527 272925008 971275424 706959112 736278170 783615461 722484387 90619431 433389755 621669631 773800724 379052020 48101859 531350264 344...
result:
ok 500000 numbers
Test #8:
score: 0
Accepted
time: 239ms
memory: 30404kb
input:
500000 1 641679119 1 46363815 1 409126743 1 301850965 1 479434398 1 8087428 1 411052661 1 274814245 1 186109822 1 557051627 1 832961130 1 468245461 1 885774901 1 205966212 1 640022376 1 40112818 1 451543633 1 116777249 1 301353585 1 865639134 1 978071440 1 696105130 1 54386476 1 950481378 1 64069307...
output:
641679119 409126743 479434398 411052661 186109822 832961130 885774901 640022376 451543633 301353585 978071440 54386476 640693072 310901737 164748344 943205363 136533544 727803925 460499039 232286575 665455084 837511803 315243095 26199131 205377168 16924774 899338264 331544...
result:
ok 500000 numbers
Test #9:
score: 0
Accepted
time: 144ms
memory: 52120kb
input:
10 994 192416571 736204386 760505341 281487941 959877974 851233214 663685576 509485978 365899785 537198264 317546803 126718048 460789228 897818658 18680833 984634479 787676854 563354285 458421086 514363741 55602674 442874164 399256047 391675537 579236972 193191514 216578877 252675142 31271148 194871...
output:
80356619 157454092 293206050 6022041 731069905 151604390 514334525 563895392 669575403 774624127 317546803 558641523 992472593 125739893 949366972 984634479 881030593 213655841 746280399 717378810 243072174 891873405 399256047 391675537 579236972 807047987 154410058 377650673 806701544 229640743 643...
result:
ok 500000 numbers
Test #10:
score: 0
Accepted
time: 126ms
memory: 40820kb
input:
10 4059 462418415 299614005 191197342 44762066 300901267 961385491 493309329 213597634 708323640 936922772 23497231 461479602 140639435 670254967 996272440 567967593 778428919 911913371 691558703 798524068 217290311 543452971 177158172 239882043 702125314 764626435 303826249 933606746 990809366 4915...
output:
462418415 299614005 191197342 44762066 300901267 961385491 493309329 213597634 708323640 936922772 23497231 461479602 140639435 670254967 996272440 567967593 778428919 911913371 691558703 798524068 217290311 543452971 177158172 239882043 702125314 764626435 303826249 933606746 990809366 491533949 60...
result:
ok 500000 numbers
Test #11:
score: 0
Accepted
time: 135ms
memory: 43136kb
input:
10 49657 477209301 840947435 604333484 622155980 678038014 465127998 957089089 894355510 968377771 949800543 862532505 722250589 268937725 969156606 245573854 500968667 899760449 185359545 330216049 769402977 835596137 37232643 40464607 103622719 539578359 384115371 545015501 704344659 315733366 841...
output:
24386105 149263245 522545322 156355561 933854795 205614293 995498647 387478497 31080083 918162413 730147773 712199885 489347745 311275833 154244381 933432658 13230008 733866425 156882463 932040286 265929098 20750751 332234430 298250715 885880707 802538280 397378619 111913092 274794813 303506899 8109...
result:
ok 500000 numbers
Test #12:
score: 0
Accepted
time: 159ms
memory: 71476kb
input:
1 500000 236077977 86078372 260030447 395969828 987989549 57339217 275325872 747113738 476061771 412580153 589144151 967633191 693832436 289364785 777281154 23767823 119804469 146277545 336859935 601994339 832084033 682171073 644911370 660086987 120599826 211375398 248467132 452293864 933711769 2134...
output:
376442474 992314650 260030447 347914044 987989549 261512576 620193765 252324505 790146989 865733342 834724719 967633191 693832436 494604333 184612685 915370675 330814922 883875013 449533217 314709314 691938928 269064599 644911370 355292009 913699960 679983605 248467132 35400898 933711769 841252659 7...
result:
ok 500000 numbers
Test #13:
score: 0
Accepted
time: 164ms
memory: 69496kb
input:
1 500000 754060142 541221496 818408807 292833795 269734500 93049742 705655834 477052382 289531753 577836666 901816346 592911223 178433769 399478363 283922345 827396041 473750582 281252938 115479501 635570951 994423568 64580695 992394937 399396922 971794709 932519987 788927885 774996990 50650116 2299...
output:
754060142 541221496 818408807 292833795 269734500 93049742 705655834 477052382 289531753 577836666 901816346 592911223 178433769 399478363 283922345 827396041 473750582 281252938 115479501 635570951 994423568 64580695 992394937 399396922 971794709 932519987 788927885 774996990 50650116 229975458 916...
result:
ok 500000 numbers
Test #14:
score: 0
Accepted
time: 169ms
memory: 69548kb
input:
1 500000 948465494 889673067 78604955 288678380 624259497 587725418 914612913 470414324 640293852 69403930 732304399 984202467 475189347 358661723 895292367 904751346 482451942 380615981 38838062 846352252 118278338 801007154 879314174 400606456 470425193 156860717 555128174 660373938 534085518 6964...
output:
682100510 69430093 885818571 433752951 55853128 688792518 262586376 340748896 446059734 917268853 348594032 2950636 384831840 755020970 899489920 635829311 684006178 834972925 840082011 289298627 171986021 9622553 639011662 141474012 211951889 579556713 801939340 729112576 48106562 188754659 4252982...
result:
ok 500000 numbers
Test #15:
score: 0
Accepted
time: 19ms
memory: 28128kb
input:
8960 4 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 2 1 1 1 1 4 1 1 1 1 1 1 1 3 1 1 1 1 4 1 1 1 1 1 1 1 4 1 1 1 1 4 1 1 1 1 1 1 2 1 1 1 1 1 4 1 1 1 1 1 1 2 2 1 1 1 1 4 1 1 1 1 1 1 2 3 1 1 1 1 4 1 1 1 1 1 1 2 4 1 1 1 1 4 1 1 1 1 1 1 3 1 1 1 1 1 4 1 1 1 1 1 1 3 2 1 1 1 1 4 1 1 1 1 1 1 3 3 1 1 1 1 4 1 1 1 1...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
result:
ok 500000 numbers
Test #21:
score: 0
Accepted
time: 102ms
memory: 39332kb
input:
10 67005 9 7 6 4 7 4 9 9 7 9 3 3 10 2 9 5 10 9 2 5 2 10 10 6 8 1 2 10 5 6 9 10 4 3 7 1 6 1 8 9 5 6 7 3 9 8 7 5 9 5 7 10 6 7 6 1 2 7 8 10 9 7 7 9 6 7 7 1 5 2 8 2 6 9 10 2 3 6 6 4 8 4 10 7 9 6 9 3 10 2 5 7 5 6 7 4 1 10 5 9 8 7 9 8 1 2 4 4 6 10 5 10 3 1 5 5 8 6 6 4 6 6 6 1 4 10 6 4 6 1 8 3 9 2 3 1 7 10...
output:
14 500000015 6 500000009 12 166666673 9 9 7 9 11 4 12 6 333333346 13 500000017 9 5 7 7 500000018 10 500000012 8 3 4 14 500000013 8 10 333333346 500000011 9 14 3 11 6 10 9 5 11 7 7 500000013 8 11 500000012 9 6 15 10 10 10 41666673 8 12 8 41666675 14 466666679 500000014 7 9 11 13 17 2 13 12 13 2 12 14...
result:
ok 500000 numbers
Test #22:
score: 0
Accepted
time: 93ms
memory: 39200kb
input:
10 16914 2 7 1 4 3 9 7 4 2 6 5 10 4 8 1 3 1 7 4 9 10 7 3 3 8 9 5 3 4 7 3 4 1 9 8 2 6 1 2 10 8 8 10 1 10 5 1 4 3 7 6 6 9 10 9 2 1 9 10 4 7 8 4 5 7 4 9 9 2 5 5 10 8 8 10 9 1 4 3 7 8 1 7 2 2 5 4 6 4 5 8 9 8 8 4 6 5 7 4 1 8 5 9 6 10 7 2 3 1 7 10 9 6 1 3 7 3 3 4 3 2 9 4 3 8 4 5 9 6 7 2 4 10 10 7 3 2 6 7 ...
output:
2 7 1 4 3 9 7 4 2 6 5 10 4 8 1 3 1 7 4 9 10 7 3 3 8 9 5 3 4 7 3 4 1 9 8 2 6 1 2 10 8 8 10 1 10 5 1 4 3 7 6 6 9 10 9 2 1 9 10 4 7 8 4 5 7 4 9 9 2 5 5 10 8 8 10 9 1 4 3 7 8 1 7 2 2 5 4 6 4 5 8 9 8 8 4 6 5 7 4 1 8 5 9 6 10 7 2 3 1 7 10 9 6 1 3 7 3 3 4 3 2 9 4 3 8 4 5 9 6 7 2 4 10 10 7 3 2 6 7 10 1 3 10...
result:
ok 500000 numbers
Test #23:
score: 0
Accepted
time: 115ms
memory: 45488kb
input:
10 10563 3 5 7 7 5 8 2 8 4 9 8 3 1 2 10 3 10 4 1 9 10 6 6 1 3 10 7 9 8 9 3 4 4 4 3 2 9 8 9 8 6 2 2 8 4 9 6 4 5 3 10 8 7 5 3 10 7 10 1 4 1 5 6 1 10 5 5 2 6 9 8 4 1 9 7 10 7 1 5 1 8 8 9 1 1 6 3 4 7 3 2 6 8 2 5 10 10 7 4 3 7 8 4 9 2 3 4 3 3 3 8 7 4 6 7 3 3 3 10 6 10 5 6 1 7 8 8 2 9 3 7 8 3 10 4 9 9 2 1...
output:
359751463 904874554 229938470 882195861 780949275 331791745 624581548 197629788 252226236 627961650 667718837 660026072 455781815 805394160 10 388559555 10 160787255 702850047 620730839 10 778440331 558485864 171429465 77425246 10 691871232 502091382 30487404 294023469 251001865 255633120 690181718 ...
result:
ok 500000 numbers
Test #24:
score: 0
Accepted
time: 136ms
memory: 69412kb
input:
1 500000 5 5 3 1 1 10 4 5 1 7 5 6 10 3 6 7 7 3 5 3 4 8 1 7 6 9 10 2 6 3 6 3 4 7 10 10 10 5 6 9 6 6 2 10 3 5 1 2 8 4 1 8 6 1 1 1 4 9 9 5 5 5 5 10 10 1 7 2 1 10 5 5 6 3 2 7 1 10 8 2 1 10 8 10 5 5 1 4 5 9 4 1 8 3 8 7 6 9 1 8 2 5 5 10 1 10 1 6 1 9 3 4 3 9 4 6 2 10 5 6 8 5 3 8 8 4 3 4 6 9 2 6 10 6 9 1 8 ...
output:
8 14 500000008 4 11 10 9 5 5 7 6 13 10 5 6 15 500000011 11 12 500000011 500000010 11 7 8 833333346 10 11 11 13 333333340 10 12 12 16 500000016 10 10 15 11 9 500000013 833333346 7 10 6 666666678 4 4 8 10 5 466666678 666666678 5 11 3 9 10 9 15 333333341 15 11 10 10 2 166666675 7 5 10 12 125000006 7 50...
result:
ok 500000 numbers
Test #25:
score: 0
Accepted
time: 132ms
memory: 71604kb
input:
1 500000 4 6 8 1 7 4 10 10 1 6 6 2 5 3 2 4 5 4 7 5 2 10 3 2 6 7 6 3 4 4 5 8 3 2 6 10 6 5 8 2 10 9 8 1 3 3 1 1 5 1 8 9 10 1 7 9 4 10 1 9 2 5 7 2 8 6 7 6 4 8 6 3 7 7 10 5 10 1 4 6 8 4 6 2 4 7 6 9 9 4 4 4 5 4 8 4 5 9 8 9 5 7 4 3 2 7 9 7 1 10 5 4 3 6 2 1 2 3 4 3 3 9 5 10 2 8 10 9 3 3 4 2 3 6 2 7 3 6 7 8...
output:
4 6 8 1 7 4 10 10 1 6 6 2 5 3 2 4 5 4 7 5 2 10 3 2 6 7 6 3 4 4 5 8 3 2 6 10 6 5 8 2 10 9 8 1 3 3 1 1 5 1 8 9 10 1 7 9 4 10 1 9 2 5 7 2 8 6 7 6 4 8 6 3 7 7 10 5 10 1 4 6 8 4 6 2 4 7 6 9 9 4 4 4 5 4 8 4 5 9 8 9 5 7 4 3 2 7 9 7 1 10 5 4 3 6 2 1 2 3 4 3 3 9 5 10 2 8 10 9 3 3 4 2 3 6 2 7 3 6 7 8 9 2 1 1 ...
result:
ok 500000 numbers
Test #26:
score: 0
Accepted
time: 132ms
memory: 69392kb
input:
1 500000 7 5 7 9 6 8 9 7 7 6 9 10 9 2 8 10 3 7 3 8 4 3 6 8 7 2 8 1 3 9 9 2 1 2 10 9 1 6 6 3 8 1 9 7 3 9 4 5 9 10 4 6 5 9 7 10 5 8 2 10 2 9 5 5 5 5 10 10 3 7 5 9 2 2 2 8 10 8 10 8 8 6 8 6 9 9 4 7 8 5 10 5 7 3 9 4 5 5 2 2 7 10 8 5 10 4 1 3 9 10 3 3 5 7 1 8 4 4 2 1 1 4 4 4 5 1 10 3 6 7 3 3 10 8 5 5 10 ...
output:
462112908 186469809 262064455 63411492 637682425 514400267 196326361 197872791 406399452 740931342 766405371 10 765506310 699470483 981049388 10 470321228 123104881 557052498 638288554 859624102 874692165 308022536 389955065 439471174 374625485 581136339 703921497 550083135 623211921 950094019 89393...
result:
ok 500000 numbers
Test #27:
score: 0
Accepted
time: 87ms
memory: 33888kb
input:
100 5796 2 2 2 2 2 2 2 2 2 2 2 4 18 20 20 20 20 20 20 20 20 20 22 23 25 31 31 34 36 36 36 37 41 61 71 71 71 71 71 71 80 88 89 89 89 89 91 91 91 91 91 96 96 96 96 96 99 101 101 101 105 113 113 115 115 117 118 118 123 137 137 140 141 141 141 146 146 146 148 152 158 169 169 169 169 169 169 169 174 179 ...
output:
10000 9989 3 3 3 3 9988 9984 9981 18 3 18 19 9981 21 9591 21 21 21 21 21 7186 44 24 37 37 34 35 37 37 37 38 44 62 7182 7173 72 77 73 72 7091 7091 7091 7091 7084 7046 92 168 164 164 95 144 97 97 96 97 101 144 102 102 143 114 114 143 116 141 121 121 136 138 141 141 142 142 142 147 164 151 149 159 159 ...
result:
ok 500000 numbers
Test #28:
score: 0
Accepted
time: 114ms
memory: 37284kb
input:
50 3890 419565 2250581 3498998 3498998 3498998 3498998 3560649 4758204 5401972 5994005 6090867 6209327 7412737 7867314 7867314 8709541 9449524 9678071 9780241 10115395 10115395 10115395 10115395 10115395 10115395 10115395 10115395 10115395 11527785 11543509 11787217 11996877 12040902 12040902 124432...
output:
999245657 999002000 3498999 999002000 3498999 982840299 4328899 5401972 10115395 6138678 6138678 7384203 10115395 8299706 8299706 10115395 9449525 10115395 10115395 10115396 982840299 982840299 10115396 10115396 11458065 10758539 10115396 10115396 982840299 35116272 35116272 12035855 32218220 309269...
result:
ok 500000 numbers
Test #29:
score: 0
Accepted
time: 165ms
memory: 30252kb
input:
100000 5 108387896 140503379 140503379 405821027 610261341 3 2 2 2 2 32115483 1 469757962 204440314 1 2 501316550 501316550 2 1 1 264930260 4 333788292 333788292 333788292 333788292 2 4 1 4 530509305 522722814 1 1 2 522499509 564102537 1 1 1 1 2 460608991 460608991 2 2 1 280089095 4 6504927 6504927 ...
output:
140503379 140503379 140503379 405821027 610261341 501316550 501316550 333788292 333788292 333788292 333788292 522499509 564102537 460608991 460608991 6504927 6504927 6504927 6504927 940930864 813991815 650871815 360812766 360812766 438612225 315161092 562393420 136926474 136926474 959850395...
result:
ok 500000 numbers
Test #30:
score: 0
Accepted
time: 153ms
memory: 63260kb
input:
2 35023 35844 58387 58387 243899 311795 376264 394938 450812 450812 450812 474115 661929 662345 662345 768959 778515 1002694 1015296 1314901 1314901 1314901 1314901 1314901 1314901 1314901 1314901 1356278 1356278 1356888 1356888 1687435 1687435 1687435 1687435 1687435 1687435 1687435 1687435 1687435...
output:
44597 17189502 67663 250034 16621662 405374 394939 1314901 1254509 450813 1209612 661930 768959 768959 1145775 934398 1015296 1015297 16621662 16544984 1314902 1314902 1314902 1314902 16514224 1687435 1356279 1498860 1401883 1383796 1687436 1687436 1687436 1687436 1687436 1687436 1687436 1687436 168...
result:
ok 500000 numbers
Test #31:
score: 0
Accepted
time: 153ms
memory: 64412kb
input:
1 500000 262 262 6642 6981 6981 14140 14140 17496 20517 26197 26197 26197 28918 28918 33764 33764 33764 33764 33764 33764 33764 33764 33764 35125 41631 43501 59782 65764 66080 66080 66933 76255 76599 77900 80394 81635 86411 95708 95708 96100 99080 99080 99080 99080 101419 101419 105386 109387 111900...
output:
999999997 12655 12655 8413 6982 14141 31667 31667 26197 26198 28918 28918 28919 28919 999999933 33765 999954912 999789183 33765 33765 103112 33765 54967 41631 54648 54075 95708 76255 76255 76255 70745 76256 77900 78016 87993 86411 86412 103112 95709 99080 101419 99081 99081 99081 101420 103112 10631...
result:
ok 500000 numbers
Extra Test:
score: 0
Extra Test Passed