QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#473580 | #4898. 基础图论练习题 | A_programmer | 100 ✓ | 462ms | 184760kb | C++17 | 4.6kb | 2024-07-12 10:39:59 | 2024-07-12 10:40:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, int> pii;
const ll mod = 998244353;
const ll inf = 1e18;
const int maxn = 5e4 + 5;
int m, q, val[maxn], id1[maxn];
int w[maxn], id2[maxn], p[maxn][150], sz[maxn], sz2[maxn];
ll n, d[maxn], qu[maxn], qv[maxn], cnt[maxn], reald[maxn][150], times[maxn][150];
bool vs[maxn];
void calcdi()
{
priority_queue<pii, vector<pii>, greater<pii> > pq;
for (int i = 1; i <= m; i++)
{
while (pq.size()) pq.pop(); pq.push(make_pair(inf, -1));
for (int j = 1; j <= sz[i - 1]; j++) pq.push(make_pair(d[p[i - 1][j]], p[i - 1][j]));
pq.push(make_pair(d[id1[i]], id1[i]));
ll nw = n, delt = 0;
while (1)
{
while (pq.top().first == delt) pq.pop();
ll x = pq.top().first - delt;
if (x == inf - delt) break; reald[i][++sz2[i]] = x;
if (!vs[pq.top().second]) p[i][++sz[i]] = pq.top().second, vs[pq.top().second] = 1;
while (pq.top().first != inf && (pq.top().first - delt) % x == 0) pq.pop();
if (pq.top().first == inf)
{
times[i][sz2[i]] = nw / x;
cnt[i] += min(nw, x);
break;
}
ll y = pq.top().first - delt, z = y / x;
if (nw <= z * x)
{
times[i][sz2[i]] = nw / x;
cnt[i] += min(nw, x); break;
}
times[i][sz2[i]] = z, nw -= x * z, cnt[i] += (nw > x ? 0 : x - nw), delt += z * x;
x += delt; pq.push(make_pair(x, p[i][sz[i]]));
}
for (int j = 1; j <= sz[i]; j++) vs[p[i][j]] = 0;
}
}
ll findid(ll x, int tid)
{
if (!tid) return x; ll nw = n;
for (int i = 1; i <= sz2[tid]; i++)
{
ll nd = reald[tid][i], nt = times[tid][i];
if (x < nw - nd)
{
ll c = min(nt, (nw - x - 1) / nd);
nt -= c, nw -= c * nd;
if (!nt) continue;
}
if (x >= nd)
{
ll c = min(nt, x / nd);
nt -= c, nw -= c * nd, x -= c * nd;
if (!nt) continue;
}
return x;
}
return x;
}
vector<pii> Mg[maxn], tb;
void solve(int l, int r, const vector<int>& nw)
{
int len = nw.size();
if (len <= 1) return;
if (l == r)
{
for (int i = 1; i < len; i++) Mg[l].emplace_back(make_pair(nw[i - 1], nw[i]));
return;
}
int mid = (l + r - 1) >> 1;
vector<pii> tb; tb.resize(len);
for (int i = 0; i < len; i++)
{
ll x = nw[i];
tb[i] = make_pair(findid(x <= q ? qu[x] : qv[x - q], mid), x);
}
sort(tb.begin(), tb.end());
vector<int> S = {tb[0].second};
for (int i = 1; i < len; i++)
if (tb[i].first != tb[i - 1].first) S.emplace_back(tb[i].second);
solve(mid + 1, r, S);
S = {tb[0].second};
for (int i = 1; i < tb.size(); i++)
{
if (tb[i].first == tb[i - 1].first) S.emplace_back(tb[i].second);
else solve(l, mid, S), S = {tb[i].second};
}
solve(l, mid, S);
}
struct DSU
{
int fa[maxn << 1];
inline int findfa(int x) { return x == fa[x] ? x : fa[x] = findfa(fa[x]); }
void init(int k) { for (int i = 1; i <= k; i++) fa[i] = i;}
bool merge(int x, int y)
{
x = findfa(x), y = findfa(y);
if (x == y) return 0;
fa[x] = y; return 1;
}
}dsu;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m >> q; vector<int> nw; nw.resize(q << 1), dsu.init(q << 1);
for (int i = 1; i <= m; i++) cin >> d[i] >> val[i], id1[i] = i;
for (int i = 1; i <= q; i++) cin >> qu[i] >> qv[i] >> w[i], id2[i] = i;
for (int i = 0; i < (q << 1); i++) nw[i] = i + 1;
sort(id1 + 1, id1 + m + 1, [&](int a, int b) { return val[a] < val[b]; });
sort(id2 + 1, id2 + q + 1, [&](int a, int b) { return w[a] < w[b]; });
calcdi(); cnt[0] = n;
if (nw.size()) solve(0, m + 1, nw);
int cur = 0, i = 1, j = 1, pid = 0; ll lst = n, ans = 0;
for (auto [a, b] : Mg[0]) dsu.merge(a, b);
while (i <= m || j <= q)
{
if (i <= m && (j > q || val[id1[i]] <= w[id2[j]]))
{
for (auto [a, b] : Mg[i]) if (!dsu.merge(a, b)) cur--;
(ans += (lst - (cnt[i] - cur)) % mod * val[id1[i]]) %= mod; lst = cnt[i] - cur; i++;
}
else
{
if (dsu.merge(id2[j], id2[j] + q)) cur++;
(ans += (lst - (cnt[i - 1] - cur)) % mod * w[id2[j]]) %= mod; lst = cnt[i - 1] - cur; j++;
}
}
cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 4
Accepted
Test #1:
score: 4
Accepted
time: 42ms
memory: 15592kb
input:
161199 9 46510 147335 540442844 159493 801351455 149342 821625305 128476 843250712 95524 275754315 139315 106523502 93575 680460786 155498 328812257 146020 410466645 79992 141967 50596784 152210 68644 268349216 72549 96959 42994091 93869 27394 945120577 2909 81886 270684270 12735 35026 871917997 974...
output:
359714743
result:
ok 1 number(s): "359714743"
Test #2:
score: 0
Accepted
time: 41ms
memory: 19884kb
input:
168549 9 49402 160577 34610415 114623 670751010 74448 676966248 53782 845469137 130729 375561046 31610 261496571 134601 154875802 136129 905308676 166248 499420220 69637 72676 875637640 160442 125460 1269794 146261 61770 714794725 137610 1291 490170432 162092 81850 488118013 106400 48193 276190368 4...
output:
520439176
result:
ok 1 number(s): "520439176"
Test #3:
score: 0
Accepted
time: 30ms
memory: 17288kb
input:
127164 9 45109 56483 490066497 70966 229077054 87305 993081887 72423 442762798 80262 200507011 101712 162752728 67532 590730535 44956 565466274 124237 429166816 13030 8906 742024040 97259 101468 187678659 13401 4301 143856524 125750 80473 258719294 106155 10339 592121345 120034 92354 50915550 112430...
output:
211463174
result:
ok 1 number(s): "211463174"
Test #4:
score: 0
Accepted
time: 40ms
memory: 16120kb
input:
158784 9 48415 138305 177767002 147417 50196642 85527 776201932 144377 990389932 118355 310906417 145220 218744495 145002 132736644 51947 834751363 139733 839880491 158443 157692 159261414 111518 14927 747973081 37498 66196 69874791 11597 115114 22394413 16704 133459 109302190 112143 46551 813021872...
output:
151875883
result:
ok 1 number(s): "151875883"
Test #5:
score: 0
Accepted
time: 18ms
memory: 11544kb
input:
111371 0 45933 13298 59545 852258097 94111 54245 459369673 40744 23311 644404848 37039 92443 220984611 17374 43165 421794343 57652 57965 470479953 62977 14481 563172671 102144 3471 36594913 46628 43278 11508424 55965 80136 777230453 56962 35374 349098036 34825 27995 339605509 43021 17657 780921827 5...
output:
92500087
result:
ok 1 number(s): "92500087"
Subtask #2:
score: 8
Accepted
Dependency #1:
100%
Accepted
Test #6:
score: 8
Accepted
time: 133ms
memory: 164880kb
input:
191116 49595 45279 87483 815631830 153579 433065789 167569 346797140 98560 154881536 170720 13622837 133236 561208103 155537 421316363 140536 514298139 6005 986290017 154400 85233907 166826 351094521 174419 304435906 173900 61174962 112778 693574534 104503 745038995 134920 31228457 117606 662581798 ...
output:
938591083
result:
ok 1 number(s): "938591083"
Test #7:
score: 0
Accepted
time: 123ms
memory: 155192kb
input:
158784 46472 48415 117545 640905746 155053 431989480 155561 63255800 142377 310683680 127120 588058774 150004 169474069 127002 588668628 150906 152304212 108743 687077799 41914 919104130 85429 816335084 132059 559711015 9237 981038801 108448 689051256 152572 446125546 151056 149667391 3602 992249821...
output:
719582900
result:
ok 1 number(s): "719582900"
Test #8:
score: 0
Accepted
time: 137ms
memory: 163092kb
input:
168163 49816 47597 129571 532707978 89007 791596146 120950 589183161 116493 617468410 89768 786647320 94035 758413684 137865 480953267 136999 487494650 134286 503698037 115468 623920627 128035 542927955 91335 776005194 150127 398148336 2766 992431297 143028 109308374 98376 730561618 135270 13761588 ...
output:
934807905
result:
ok 1 number(s): "934807905"
Test #9:
score: 0
Accepted
time: 122ms
memory: 157744kb
input:
121718 46964 48021 43354 819111261 10530 955367869 80777 501381455 69544 639333275 114691 89113603 45387 810937142 31928 865064071 89801 391744587 94263 339137420 119935 23921502 56223 766531932 108313 167240585 106757 185911175 30245 872961430 71691 612640613 102314 242401520 101122 257170039 61627...
output:
135228392
result:
ok 1 number(s): "135228392"
Test #10:
score: 0
Accepted
time: 153ms
memory: 179456kb
input:
188134 49787 48968 187895 50171716 119433 814368117 139552 750931626 132931 458299971 142653 741277533 177407 244563903 130505 469034750 145157 399488414 173707 262070086 168863 158870562 172377 35902964 140369 421860855 29507 967813282 165485 301042299 143784 737822317 162077 173448746 108264 85153...
output:
100771003
result:
ok 1 number(s): "100771003"
Subtask #3:
score: 6
Accepted
Test #11:
score: 6
Accepted
time: 2ms
memory: 11764kb
input:
569435269457904707 2 0 490445920091092693 772271583 144842828305643603 609043885
output:
884694794
result:
ok 1 number(s): "884694794"
Test #12:
score: 0
Accepted
time: 2ms
memory: 10900kb
input:
946929772456816659 2 0 589193907831915013 196301185 485768367910597533 207014034
output:
790540706
result:
ok 1 number(s): "790540706"
Test #13:
score: 0
Accepted
time: 1ms
memory: 10848kb
input:
693038683299151358 2 0 654733556025919068 724998910 450253521190874799 187460097
output:
122292064
result:
ok 1 number(s): "122292064"
Test #14:
score: 0
Accepted
time: 0ms
memory: 14672kb
input:
572269482188906358 2 0 545978502848607475 331750201 488577730099900109 477584735
output:
429885702
result:
ok 1 number(s): "429885702"
Test #15:
score: 0
Accepted
time: 0ms
memory: 11964kb
input:
984888155303961325 2 0 421568681423492040 823358650 324408005979881943 905919848
output:
551223124
result:
ok 1 number(s): "551223124"
Test #16:
score: 0
Accepted
time: 0ms
memory: 14972kb
input:
968068649251960108 2 0 932666179822285222 303897491 422068063538287737 405622211
output:
516717723
result:
ok 1 number(s): "516717723"
Test #17:
score: 0
Accepted
time: 2ms
memory: 9164kb
input:
973235486287221374 2 0 604729607242747292 566399250 440704799734330948 93237801
output:
772791524
result:
ok 1 number(s): "772791524"
Test #18:
score: 0
Accepted
time: 2ms
memory: 8820kb
input:
980842002786834388 2 0 921076927921054095 989436809 917078581302025088 354268450
output:
387335763
result:
ok 1 number(s): "387335763"
Test #19:
score: 0
Accepted
time: 0ms
memory: 12744kb
input:
584600268153835325 2 0 436736455094118542 788823700 379215887395241676 440751386
output:
178749302
result:
ok 1 number(s): "178749302"
Test #20:
score: 0
Accepted
time: 0ms
memory: 14556kb
input:
984888155303961325 2 0 421568681423492040 823358650 324408005979881943 905919848
output:
551223124
result:
ok 1 number(s): "551223124"
Subtask #4:
score: 18
Accepted
Dependency #3:
100%
Accepted
Test #21:
score: 18
Accepted
time: 35ms
memory: 19432kb
input:
569435269457904707 2 48002 490445920091092693 772271583 144842828305643603 609043885 71626464779726163 20936760728342582 933619218 254533877531926689 561120543297327423 444805145 102181371350776436 64807827761321835 63236550 442490347461393187 274703226312639148 379888813 153103619447430279 56932615...
output:
264605976
result:
ok 1 number(s): "264605976"
Test #22:
score: 0
Accepted
time: 32ms
memory: 19176kb
input:
504260032580621389 2 49361 270823699250720124 30858888 336528726133157676 686676838 411951311400351555 331964440631830249 849153007 395362490592741772 476242043133170955 233632950 183299785979517028 300783233878432816 890373397 101096990546501308 294220083765028120 482548478 30494794811726538 492575...
output:
374280020
result:
ok 1 number(s): "374280020"
Test #23:
score: 0
Accepted
time: 37ms
memory: 18000kb
input:
908984547406193258 2 49006 553146168947167785 921235648 439052241502823206 685482302 602040034167963673 319806281814227523 602421493 889680730869149610 662785644521343266 319100701 855861307841385482 123218837422189032 958395288 789474388061739888 886525713531875881 485625803 506682328285523072 8679...
output:
411258291
result:
ok 1 number(s): "411258291"
Test #24:
score: 0
Accepted
time: 35ms
memory: 16668kb
input:
645595087071518014 2 46364 502798671238091149 130131399 324145073511001064 249141640 529562079328876365 298584769486918994 793053817 104449532477780267 612956797119263913 599706657 537335025824879813 509591120306867932 422994501 3573858933523744 362779176725767538 466503134 355006270273722975 606167...
output:
3939553
result:
ok 1 number(s): "3939553"
Test #25:
score: 0
Accepted
time: 32ms
memory: 15788kb
input:
719221297460377128 2 47571 344669347369453785 109414971 630436210393683647 527587080 494442208767214644 568762326175380228 274970054 57477492106404787 655245493834324395 382109587 22155928017304041 59482593547715744 873161380 187440545343246007 190303544007160534 159038457 506940482480256741 6413591...
output:
70514973
result:
ok 1 number(s): "70514973"
Test #26:
score: 0
Accepted
time: 32ms
memory: 14200kb
input:
895088201401004405 2 45041 276028463639596405 456551182 805436189268999970 73771 21429629043534406 631368195310636941 265763227 662737085246639506 143087521945488388 635548439 377675072184922400 804129509385729008 716798383 350029179084366085 117553290957648227 20894738 122339684090997249 7205501057...
output:
559035760
result:
ok 1 number(s): "559035760"
Test #27:
score: 0
Accepted
time: 50ms
memory: 19288kb
input:
853901589698398947 2 47600 504553695105130092 847799116 138986940711272376 645918409 805868840752605206 78417023376575599 841040724 729516722093143233 218204564225574757 336393903 730920155682863361 695576676583032360 406662382 387801338291686723 202931704070108854 337663750 247673343610665743 24573...
output:
20383713
result:
ok 1 number(s): "20383713"
Test #28:
score: 0
Accepted
time: 25ms
memory: 16508kb
input:
670502957421329993 2 45217 483745611802893710 733999054 668071203574411469 828666336 420971137268931813 366553146611242395 965231439 287424331604163221 506949430264341972 601249827 149442959137057706 557729764807337099 145435283 24271514949210121 655375054865364550 969273095 570625553631888431 32471...
output:
937105664
result:
ok 1 number(s): "937105664"
Test #29:
score: 0
Accepted
time: 31ms
memory: 17784kb
input:
563845195733711553 2 48989 229866420401531786 558292747 545061569237416562 6907852 132266473456293640 75289038464304103 118029834 32731247863057693 356593250668739234 378210865 66114516634328274 92146176364809198 445824305 231042900349456054 325921825145329565 425319020 423843183122176900 5050925061...
output:
651838351
result:
ok 1 number(s): "651838351"
Test #30:
score: 0
Accepted
time: 31ms
memory: 15636kb
input:
804068805652796381 2 45790 713896086745970460 932094415 451836086076043686 180589234 797324209326094324 458554421458651867 300552452 666099368215435761 398615680976044224 517160772 93127604003167259 65073324216076012 364948453 746562120109527370 478791782647716593 625536788 584650813747492507 584407...
output:
91959720
result:
ok 1 number(s): "91959720"
Subtask #5:
score: 12
Accepted
Test #31:
score: 12
Accepted
time: 4ms
memory: 15880kb
input:
755526150476311190 942 0 492334667739348527 1 755523898623296976 1 532486636690994793 1 755526150476030559 1 755526150476249097 1 502164090270592200 1 657422656495814703 1 487200614853438190 1 311037325561173142 1 755526150475651155 1 125287404340238660 1 755524914808674090 1 755526150476177007 1 75...
output:
546044429
result:
ok 1 number(s): "546044429"
Test #32:
score: 0
Accepted
time: 0ms
memory: 15884kb
input:
507397654005748030 973 0 507391491616563534 1 486814015790119176 1 333131389050214032 1 363564475994643564 1 465930313898633808 1 139522156177690314 1 507395579080257474 1 86630001225723132 1 507395634795467574 1 507396923359845774 1 472957579895774142 1 211220548093936200 1 507397483302327114 1 507...
output:
873803086
result:
ok 1 number(s): "873803086"
Test #33:
score: 0
Accepted
time: 3ms
memory: 15244kb
input:
603106685583649335 921 0 550056634223640253 1 603106685583649293 1 603106685583647605 1 603106685583643690 1 603106685583647260 1 603106685583645101 1 603106685583206332 1 603106685583646490 1 579053271797467737 1 603106685567627560 1 392817087439609936 1 603106685583643465 1 603106685583648090 1 60...
output:
249400664
result:
ok 1 number(s): "249400664"
Test #34:
score: 0
Accepted
time: 0ms
memory: 15496kb
input:
548596182165075765 943 0 548596176080168583 1 548596182156180063 1 312480420249896937 1 548596163341594933 1 526283600729694623 1 548596158109050143 1 403131997716059924 1 434962771902913720 1 503166563025971068 1 334309818515550442 1 548596177929282553 1 548596181450546783 1 548596147814225823 1 54...
output:
315888763
result:
ok 1 number(s): "315888763"
Test #35:
score: 0
Accepted
time: 3ms
memory: 16168kb
input:
757339678164545873 914 0 639318686980737134 1 746121423482808728 1 757339678163450618 1 742690258664301578 1 615075436001700347 1 735156649863536078 1 748312116661086428 1 720777012721160772 1 733811525870561678 1 746526366212816378 1 743741354498887825 1 753440640705502328 1 735178291510182878 1 72...
output:
748030011
result:
ok 1 number(s): "748030011"
Test #36:
score: 0
Accepted
time: 3ms
memory: 16004kb
input:
678523609535069397 961 0 678523501457247993 1 678341707003179753 1 678213366219732921 1 596032992350559535 1 595323423910072641 1 178264171486256288 1 678331675351935897 1 353022445409011341 1 653752496830522075 1 662470342111950027 1 587709190707850701 1 678270056924891769 1 677027683908676175 1 67...
output:
562697340
result:
ok 1 number(s): "562697340"
Test #37:
score: 0
Accepted
time: 0ms
memory: 16108kb
input:
657959922343486841 902 0 650132742778059115 1 105135315791795180 1 438709014360864607 1 545602442587344080 1 657551739592023011 1 656791446287459707 1 657959922133303499 1 647469446648658309 1 657959922343384019 1 657959922221719769 1 336017444559583475 1 657959922253125629 1 655097797158940969 1 19...
output:
300994893
result:
ok 1 number(s): "300994893"
Test #38:
score: 0
Accepted
time: 0ms
memory: 15488kb
input:
545476271566415902 948 0 502943849064064720 1 545153141190505744 1 493528954491284005 1 487490221799012640 1 391805643829976272 1 545466964425150144 1 545474613254014704 1 545475659935859328 1 48415031136648176 1 545475230527923072 1 545472466214333424 1 545475176851931040 1 405305381846539616 1 393...
output:
621606394
result:
ok 1 number(s): "621606394"
Test #39:
score: 0
Accepted
time: 3ms
memory: 14880kb
input:
768089367882777564 903 0 768042195730743057 1 624180099065408353 1 677932298998893337 1 761912479820021969 1 373002333986242953 1 681859753068860049 1 768089367882777309 1 580672767835556559 1 768089367882750069 1 51197080622037114 1 737402458661389169 1 768089367882765501 1 707354099585711345 1 768...
output:
319523314
result:
ok 1 number(s): "319523314"
Test #40:
score: 0
Accepted
time: 0ms
memory: 12208kb
input:
803879216581914933 998 0 498552666676978841 1 803189592600095992 1 803577182309491044 1 803875534594601716 1 803827683448699636 1 803767099629307124 1 803775818980883188 1 803799950365214452 1 803816279020876020 1 803806021800931060 1 803585821604611604 1 695090981117645328 1 803690137369875484 1 68...
output:
867132754
result:
ok 1 number(s): "867132754"
Subtask #6:
score: 12
Accepted
Dependency #3:
100%
Accepted
Dependency #5:
100%
Accepted
Test #41:
score: 12
Accepted
time: 0ms
memory: 16560kb
input:
658450692215768892 966 184 215944253331969524 463889684 658450636472429991 583551110 658450692215733673 179443509 658450692215624997 605779678 508574445107762299 859274405 658450681194937638 515630669 63736085272552748 994573345 354907806666837319 932072760 658450692214054043 663256872 6584506911545...
output:
12943668
result:
ok 1 number(s): "12943668"
Test #42:
score: 0
Accepted
time: 0ms
memory: 16748kb
input:
503100602634994293 941 197 502254941823458923 410719580 502449274817977963 533547443 502177856576665963 308661716 503100602634994286 848364395 502374606833359723 403813521 500909455018842115 763372389 436423359815749426 878348769 502539379040627347 691350061 500478693279270763 227006141 502429907131...
output:
364124022
result:
ok 1 number(s): "364124022"
Test #43:
score: 0
Accepted
time: 2ms
memory: 15028kb
input:
794543759708235787 990 200 794543751390436516 498296758 710761081263791990 541764893 794543758436298068 338401430 764875891357270304 761817879 735614769808273484 635855135 794543754989372684 409779107 717851578458891300 765401991 161042388300387362 617871045 511627804824526915 940296882 794543756648...
output:
69328383
result:
ok 1 number(s): "69328383"
Test #44:
score: 0
Accepted
time: 4ms
memory: 16600kb
input:
565276290672233192 964 187 565276290670765530 537786598 565276290502116615 193903398 565276290671867680 489303416 383466025969347505 426331410 565276288985082995 229639082 535558729837813905 325909644 474196520248462440 639989576 307149486876119700 818820866 565276290671678355 504462133 565276290446...
output:
631847000
result:
ok 1 number(s): "631847000"
Test #45:
score: 0
Accepted
time: 5ms
memory: 16884kb
input:
719500283503014592 940 191 596954007460465466 459554486 711843970141183964 193724011 662050619203756685 326598696 687071628534410294 147562554 671522026560145754 166094666 632739715281611294 435823622 629554949383658196 880683852 719500283450265202 559607128 430055232270736641 937845392 644024279806...
output:
537913133
result:
ok 1 number(s): "537913133"
Test #46:
score: 0
Accepted
time: 4ms
memory: 15216kb
input:
746081052613716768 968 186 114806715755696720 513769389 746081051437216030 737208639 746081050913326390 761645235 610859457429446257 863358451 384587317556948678 937572929 745110336760534160 247865779 136264144005106400 510157400 746050759360662160 25053097 744815172303539440 141073649 7451915550759...
output:
802963512
result:
ok 1 number(s): "802963512"
Test #47:
score: 0
Accepted
time: 0ms
memory: 13832kb
input:
838569256262277534 902 194 368691841488556872 548966575 829187927329664760 439579643 599012418708046200 321256268 99251099043250440 385138871 666529761967066140 305621549 838569256260878142 77869183 242796476636375376 563943468 115450425805486200 223598230 473794040645928288 526038447 52249254896767...
output:
902343531
result:
ok 1 number(s): "902343531"
Test #48:
score: 0
Accepted
time: 4ms
memory: 13924kb
input:
760989644838376533 918 184 760989644837357739 253937074 760989644735019972 299540701 721179032823874952 367005016 737774529756321877 63616085 676404669053970597 413375592 760989644763128262 467319659 696835782280314477 162526593 760989638053297620 744413973 256689804086807511 609569539 6462443154065...
output:
255884156
result:
ok 1 number(s): "255884156"
Test #49:
score: 0
Accepted
time: 4ms
memory: 13964kb
input:
605066708578608907 985 195 605040377919406881 845020040 605066682441689774 600561672 605066708559869524 61659795 570731240318881512 736991447 605066708545791824 69236017 605066702556562799 451865546 605045604828879780 81156584 605066708578248274 113710627 520890466933562693 888100231 510935353837155...
output:
30494216
result:
ok 1 number(s): "30494216"
Test #50:
score: 0
Accepted
time: 2ms
memory: 15384kb
input:
707923123776380648 960 191 707923123776375484 799176622 164813810270485419 975427804 446662266871612830 721645063 706273141785672657 596852756 707923108287090339 101641673 466130775646175913 938132930 141563786833129006 981855402 111394344057775227 983059268 707923119233185773 27527747 6649052793931...
output:
37261270
result:
ok 1 number(s): "37261270"
Subtask #7:
score: 12
Accepted
Dependency #3:
100%
Accepted
Dependency #5:
100%
Accepted
Test #51:
score: 12
Accepted
time: 55ms
memory: 151676kb
input:
571630416836886394 47168 0 96863681397862733 975125142 356044822253140262 598706048 515453346882217082 780566337 310612673285348975 628963074 470413750105710996 521531320 485023891192396182 511014543 294586905153825661 925671185 571630416738335094 158726562 185789055211250703 954614799 3548394816997...
output:
563260749
result:
ok 1 number(s): "563260749"
Test #52:
score: 0
Accepted
time: 43ms
memory: 150808kb
input:
841161310096886484 47782 0 695723253916094448 724478598 540665669817327612 824722094 841159307153505572 358568703 420009767990047350 208597811 841157041808575787 461740092 841153463198963867 569722258 841155889630106597 515332698 835476875635312659 636252803 841161310096575364 268569091 665233067738...
output:
178000363
result:
ok 1 number(s): "178000363"
Test #53:
score: 0
Accepted
time: 43ms
memory: 147848kb
input:
539025190773540771 46142 0 539025114552193483 750084891 539025146939174001 208399611 539025142948200821 59628495 539025167040882541 187485048 297804195276627820 596910027 539025036251289721 292620891 539025176171348121 25151122 419197658222546676 541151443 539025182999530881 170481735 94373350744432...
output:
792619156
result:
ok 1 number(s): "792619156"
Test #54:
score: 0
Accepted
time: 69ms
memory: 151480kb
input:
705921968914365511 47716 0 705921968910682250 37456241 216562629047838980 788958895 705921968888183480 220262214 504364558319371214 712517838 705921968912285852 63040139 559896530157610827 865295481 692795819065070003 265936336 705921968902391426 525007326 705921968898107858 563844710 45377210899051...
output:
441700676
result:
ok 1 number(s): "441700676"
Test #55:
score: 0
Accepted
time: 61ms
memory: 154036kb
input:
564133086769866350 48875 0 563437196556182544 261486038 560294783129522064 324772044 556631029930923984 145670740 559700141975322384 85009595 314575623929155476 914739751 557994542117070864 119723133 563970481727376144 4644345 556297791301355844 658135589 473151054735727950 815276832 549167714478150...
output:
310639483
result:
ok 1 number(s): "310639483"
Test #56:
score: 0
Accepted
time: 50ms
memory: 149772kb
input:
936756643107884507 47057 0 936756549937799391 463453118 936756642116110143 96749536 936756552075454317 459354765 936756643099480707 8057801 936756597512789337 306600323 936756596879434857 309660796 465274780883248915 884923508 936756624706549095 179625651 936756643107883335 82112034 8680557778246200...
output:
628129359
result:
ok 1 number(s): "628129359"
Test #57:
score: 0
Accepted
time: 70ms
memory: 150224kb
input:
702873086596726417 46921 0 702873084504467311 435498634 299151456816761100 696668178 702873086593780755 188996895 702873085139720895 378933418 287632236113773418 945140906 702873086596626031 8514228 381034645003012276 917283692 702873085223824163 371177051 480867097500933640 624812518 70287308659425...
output:
296470561
result:
ok 1 number(s): "296470561"
Test #58:
score: 0
Accepted
time: 56ms
memory: 154260kb
input:
696868150883245690 48306 0 476810224399322700 854659018 464195603276193600 304310171 446344869551578397 871173576 73772786710123200 427101535 499665574666792800 284452466 346762905048896444 928674821 283641472225843200 145545531 684797240141935200 12699482 263903781116001600 148139221 42026490439052...
output:
178187268
result:
ok 1 number(s): "178187268"
Test #59:
score: 0
Accepted
time: 56ms
memory: 154032kb
input:
995646392343469795 49194 0 995646392329767108 312459955 995646392334135924 245193472 995646392331093996 299744392 995646392321756100 363274045 968605994456210365 485812394 499093046036246318 925126426 995646392341599912 108726352 995646392333878812 250022020 728936689913383683 819169473 714935731010...
output:
664181186
result:
ok 1 number(s): "664181186"
Test #60:
score: 0
Accepted
time: 59ms
memory: 153764kb
input:
802473733444905042 48027 0 415952639582201792 589867404 802473733444442582 39725642 446316590121917984 571300735 22582790395893058 993586735 365938749924876688 605026635 802473733429621382 259044778 14458547092095008 673264904 430697237683964416 901111452 437186563439513194 897704884 802473733433003...
output:
291107795
result:
ok 1 number(s): "291107795"
Subtask #8:
score: 10
Accepted
Dependency #5:
100%
Accepted
Test #61:
score: 10
Accepted
time: 260ms
memory: 176140kb
input:
716429171502522215 47121 48854 684206275836370608 1 447368400898092275 1 500447584334752997 1 380938825102517800 1 703571667242752149 1 432997187680148804 1 169070786477357537 1 702163195024687605 1 706006848814479885 1 714728181809868081 1 702992487375782988 1 695502249468972696 1 29949334130159091...
output:
358321674
result:
ok 1 number(s): "358321674"
Test #62:
score: 0
Accepted
time: 239ms
memory: 180732kb
input:
760962402402047624 47788 46028 760962402400520977 1 146627560121093112 1 552500521368356496 1 609213278868935512 1 336266088659361952 1 556168263038283744 1 372691194708123248 1 542056449397110112 1 677262387740868256 1 760962402401092996 1 658355484638429264 1 760962402400992112 1 64514813498907734...
output:
397036874
result:
ok 1 number(s): "397036874"
Test #63:
score: 0
Accepted
time: 235ms
memory: 180500kb
input:
823454131189228931 47545 47996 633913455457088435 1 823454131188293887 1 823453960526785252 1 295577193570436898 1 448054862139934560 1 823454131188121371 1 662676467650910604 1 823454131188972663 1 702788755769685000 1 823453314863152631 1 823453107324243081 1 593195757060130275 1 82345390310591764...
output:
556901026
result:
ok 1 number(s): "556901026"
Test #64:
score: 0
Accepted
time: 227ms
memory: 175756kb
input:
790661905382541343 46638 46580 790661830315353694 1 628815916342495006 1 414195221334706964 1 761278128956231679 1 506248255650008574 1 504165239321589346 1 708623989919201733 1 537606289579523112 1 790661883086104374 1 790661830631248034 1 577869563291089149 1 790661889734095294 1 22748820983416533...
output:
923583785
result:
ok 1 number(s): "923583785"
Test #65:
score: 0
Accepted
time: 238ms
memory: 182336kb
input:
543995107469111870 46815 49986 543995107427386090 1 543995107385280202 1 543995107360534954 1 543995107322490794 1 543995107359865494 1 543995107430990394 1 118258633661474253 1 543995107437907018 1 543995107400709066 1 543995107388815822 1 543995107403911386 1 514372106427243364 1 54399510735645175...
output:
549708819
result:
ok 1 number(s): "549708819"
Test #66:
score: 0
Accepted
time: 256ms
memory: 173852kb
input:
973680848449912174 45809 48893 558451142980027913 1 973149521190732051 1 973151795384428051 1 730813052917184451 1 782733029576651051 1 973030580860431251 1 653086705192012191 1 885279135122797234 1 972841595364293651 1 940582507995263351 1 973068702032260451 1 762862562432814731 1 85928041435845971...
output:
760343391
result:
ok 1 number(s): "760343391"
Test #67:
score: 0
Accepted
time: 236ms
memory: 171068kb
input:
769083325181598713 45572 45512 768897660622302008 1 769083325180938609 1 768647443362725330 1 768852015940427126 1 43555486635844404 1 768689595631618217 1 769075697253837284 1 768598532992141964 1 768929558164370306 1 769077417931272476 1 768791432304759608 1 461513625257788477 1 518464733738942569...
output:
724840598
result:
ok 1 number(s): "724840598"
Test #68:
score: 0
Accepted
time: 228ms
memory: 181480kb
input:
989697766657099563 45914 49705 219852197404383689 1 491494304787067673 1 872190190190847836 1 887483404175496314 1 988437667010051631 1 988332948976172748 1 473918774016572392 1 73539620003504958 1 988923292997857377 1 142884498556990175 1 988698815467334790 1 936770813461610494 1 783682329635155073...
output:
478142716
result:
ok 1 number(s): "478142716"
Test #69:
score: 0
Accepted
time: 222ms
memory: 175560kb
input:
508086302629220899 45255 46961 508086302479732309 1 508086302451729729 1 476932514196496909 1 508086302347313329 1 479954970836181675 1 459285673375846471 1 487091876268376921 1 322586470409639114 1 472604100878658625 1 420442380335293898 1 278461218906312954 1 480604960680766945 1 28492141885045535...
output:
647915375
result:
ok 1 number(s): "647915375"
Test #70:
score: 0
Accepted
time: 267ms
memory: 184760kb
input:
608163868156115674 49705 47751 503333959958709384 1 421780903089450717 1 555039048741370741 1 532830641628222627 1 511986453645349407 1 542988393154824354 1 600140273623136626 1 412811087999765945 1 554352422959823718 1 594499283127331680 1 503907834436640092 1 608163868148396758 1 48888827368907290...
output:
64753822
result:
ok 1 number(s): "64753822"
Subtask #9:
score: 18
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Dependency #7:
100%
Accepted
Dependency #8:
100%
Accepted
Test #71:
score: 18
Accepted
time: 462ms
memory: 182532kb
input:
679891637637612258 50000 50000 259695496911122585 3 420196140727489673 4 679891637637612256 2027 679891637637612255 3027 679891637637612254 4027 679891637637612253 5027 679891637637612252 6027 679891637637612251 7027 679891637637612250 8027 679891637637612249 9027 679891637637612248 10027 6798916376...
output:
107623205
result:
ok 1 number(s): "107623205"
Test #72:
score: 0
Accepted
time: 348ms
memory: 170708kb
input:
679891637637612258 50000 50000 679891637604057827 499122176 679891637637612253 337515298 679891603277873891 499122178 679891637637612243 392765101 679874045451567843 499122180 679891637637612233 423263599 679891568918135523 499122182 679891637637612223 289099264 679821268893434595 499122184 67989163...
output:
569698160
result:
ok 1 number(s): "569698160"
Test #73:
score: 0
Accepted
time: 209ms
memory: 157068kb
input:
948544025771541843 47705 48241 665961317897552836 865383491 913521057238898328 321461212 802569018146208567 714191686 905851662205797168 84344222 852266398982029728 177715882 944927227933412652 756516239 871376098607791020 392851798 740277580691655969 503741996 796261373196170731 814596935 852166748...
output:
199697115
result:
ok 1 number(s): "199697115"
Test #74:
score: 0
Accepted
time: 231ms
memory: 165012kb
input:
608183873523864734 49807 49636 608182906030651046 700302279 608182720784187326 175396751 608182939317163646 695735691 312569148464445746 941702838 456389914333564186 869248352 608183497160555246 629711235 608181773625637526 771406387 608181452197157366 783032386 608182872258042926 157797468 23909756...
output:
717327244
result:
ok 1 number(s): "717327244"
Test #75:
score: 0
Accepted
time: 248ms
memory: 168164kb
input:
626634888274625027 48138 46352 626632624129802836 319313279 485972420179095841 693488928 626629446078584429 504529664 626629931852851092 486457000 382625277630777707 804298910 626633432802726958 232835980 422950034858526254 762146119 364325128097036886 824879901 378776238699959651 808722577 33464447...
output:
770722987
result:
ok 1 number(s): "770722987"
Test #76:
score: 0
Accepted
time: 254ms
memory: 171412kb
input:
922901184145313741 47172 45827 768370392367262009 698681755 644958316115273895 779815807 763511026753670004 148205215 86106913981822367 979885150 714939037462012584 339421835 767290788884294315 699409445 801674764695007164 282941671 796790243322833928 286326167 522384918049460088 463210721 582154017...
output:
133950031
result:
ok 1 number(s): "133950031"
Test #77:
score: 0
Accepted
time: 235ms
memory: 158104kb
input:
876489360929190321 48680 48634 876489329958132820 367264461 876489336794333580 352906185 521647171081631200 522491788 600909340018286160 494876232 535429580000481227 915573328 853205548340832409 610743390 625331467022528625 883944805 618349099234165040 489350690 603543069291569998 890839703 87648935...
output:
729106535
result:
ok 1 number(s): "729106535"
Test #78:
score: 0
Accepted
time: 328ms
memory: 171936kb
input:
672729791457629566 49475 47572 672672867072408014 157010667 672721843222611014 25407598 535382218139183811 858753364 672599121231793574 521641531 644463684285509595 811733514 672498013883752794 571668800 672650984039837054 299882579 672543776246853434 556563366 580107095487893429 838876654 672710691...
output:
523978435
result:
ok 1 number(s): "523978435"
Test #79:
score: 0
Accepted
time: 251ms
memory: 169980kb
input:
678974468101491816 47584 45075 490282678576250607 188616167 427993998479002328 860675466 544886700520065852 778928083 623120786473708762 727215408 678974461847038584 410511769 573122140339476584 761086573 569227950381216699 763410841 411391170890797988 872289959 639007019147453347 716220641 59541549...
output:
28998680
result:
ok 1 number(s): "28998680"
Test #80:
score: 0
Accepted
time: 362ms
memory: 167952kb
input:
972871333641478507 47006 47798 885719434912290372 643259195 737124273593094735 197113335 972871310500220962 557892771 686654087546621568 230727021 686136333853866622 768312729 25013757428039181 993264796 972871303822561657 566234648 972871333641475551 24369631 972871333641474613 31244283 54590751692...
output:
691212404
result:
ok 1 number(s): "691212404"
Test #81:
score: 0
Accepted
time: 244ms
memory: 159156kb
input:
791939461591559266 47763 47035 574634820408917354 853554123 786423548972171880 270693769 791857524752494200 75919089 791782329291874200 141945147 791798980687054200 128183761 700384893726632495 796295589 100276458293527280 983331195 791736059421304200 183021885 791815785529444200 113882414 715188722...
output:
619229361
result:
ok 1 number(s): "619229361"
Test #82:
score: 0
Accepted
time: 187ms
memory: 167824kb
input:
555337566850339657 49398 46844 473670354877049596 751782001 555337509673848222 356103589 555299805276633915 444812259 324992407370581327 880684175 555277560914292108 491626418 555337566751275534 8516706 7070853636809601 996111844 555250413519228666 548031788 555337512313649454 349426898 555337540360...
output:
63318685
result:
ok 1 number(s): "63318685"
Test #83:
score: 0
Accepted
time: 247ms
memory: 173584kb
input:
889656026262543908 47299 47657 532785318078119786 369383946 813281016117600606 82422234 364287551037113898 432870995 574597596499636436 772424077 255811360277025238 468564861 760294426844272053 135334440 716591301040241532 657394043 643295884491593839 717771160 596695995750163233 754860264 877028110...
output:
494120126
result:
ok 1 number(s): "494120126"
Test #84:
score: 0
Accepted
time: 258ms
memory: 158416kb
input:
811742286444752740 49869 45786 620549241468524426 846212552 298178849510929657 219842630 441023549600249482 924867553 799298852915287855 485122674 534029658597158257 885063847 164691537357628803 242574946 282779793127203593 223112508 509399138232364811 403770589 575901828615754099 135542374 53261444...
output:
282477051
result:
ok 1 number(s): "282477051"
Test #85:
score: 0
Accepted
time: 333ms
memory: 166504kb
input:
551843030664275097 46816 49774 480321587952323367 387315509 481145811190884049 799823251 529061989747925612 768628784 551843030630673089 584542142 528439936290098121 304385530 551843030653366633 530697570 551843030617766769 112042457 551843030631914465 78958395 245727502372859017 942831436 551843030...
output:
263840701
result:
ok 1 number(s): "263840701"
Test #86:
score: 0
Accepted
time: 264ms
memory: 159992kb
input:
695740247191993714 45274 49586 695740245476002465 26678829 583389826728047072 114036498 558708289903363248 625324567 663064778701631952 386495912 695740223952757264 323199695 503340825213218085 869274162 695740245400729804 27430358 592799932227407264 483500687 526257751238382336 528613662 6074539788...
output:
364102077
result:
ok 1 number(s): "364102077"
Test #87:
score: 0
Accepted
time: 212ms
memory: 159620kb
input:
803672178451762542 46571 47976 803672176480238992 41353609 803672158532768372 204367402 803672173463784272 70587991 123740372961347912 682715889 784358922266725344 417040826 803672140415134332 283830586 493824678579266496 579228999 160301916825004902 969805740 325557431251446240 645850051 8036721557...
output:
926524455
result:
ok 1 number(s): "926524455"
Test #88:
score: 0
Accepted
time: 237ms
memory: 169964kb
input:
542663089978439686 49043 47166 478447018463808744 747723884 542662908957721109 180735288 301434058588494780 642433065 504802078125187317 437111329 419957581879756254 542931345 542662780824180494 251681746 542663089944935519 29627680 160928755380179120 952215390 542662270504696400 384126422 542662319...
output:
360681385
result:
ok 1 number(s): "360681385"
Test #89:
score: 0
Accepted
time: 322ms
memory: 174432kb
input:
761276334002768610 46641 47253 459592709811820396 812340600 761276333939916586 319187505 761276333896085561 443742627 761276333975331660 176954516 717076096060641837 570281387 761276333838291753 521668274 711605124777968269 19512385 669044439994687161 614279524 598012841256440261 681492115 761276333...
output:
710969269
result:
ok 1 number(s): "710969269"
Test #90:
score: 0
Accepted
time: 279ms
memory: 162848kb
input:
887346371914600108 45473 49488 861749066683155840 388183238 865559371792122630 386488574 539487193185627995 558527016 862700801221317555 387690253 481528352243493065 261435400 399714854788414200 928421999 419547218446075267 924842846 770884021281917270 95196692 512637390870536225 243352360 772205696...
output:
468588441
result:
ok 1 number(s): "468588441"
Extra Test:
score: 0
Extra Test Passed