QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#783957 | #6660. 택시 여행 | jiamengtong | 0 | 3ms | 14972kb | C++14 | 2.3kb | 2024-11-26 12:23:42 | 2024-11-26 12:23:44 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define M 100005
using namespace std;
vector<pair<ll, ll> > v[M], G[M];
ll sz[M], hson[M], fa[M], dep[M], dis[M], top[M], ndis[M], vis[M];
void dfs(ll x, ll ft)
{
sz[x] = 1;
fa[x] = ft;
dep[x] = dep[ft] + 1;
for(auto t : v[x])
{
int to = t.first, dist = t.second;
if(to == ft) continue;
dis[to] = dis[x] + dist;
dfs(to, x);
sz[x] += sz[to];
if(sz[to] > sz[hson[x]]) hson[x] = to;
}
}
void dfs1(ll x, ll tp)
{
top[x] = tp;
if(hson[x]) dfs1(hson[x], tp);
for(auto t : v[x]) if(t.first != fa[x] && t.first != tp) dfs1(t.first, t.first);
}
int LCA(ll x, ll y)
{
while(top[x] != top[y])
{
if(dep[top[x]] < dep[top[y]]) swap(x, y);
x = fa[top[x]];
}
if(dep[x] > dep[y]) swap(x, y);
return x;
}
priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > pq;
std::vector<long long> travel(std::vector<long long> A, std::vector<int> B, std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
int n = A.size();
for(int i = 0; i < n - 1; i++) v[U[i]].push_back({V[i], W[i]}), v[V[i]].push_back({U[i], W[i]});
dfs(0, -1);
dfs1(0, -1);
for(ll i = 0; i < n; i++) for(int j = 0; j < n; j++) if(i != j)
{
ll dst = dis[i] + dis[j] - dis[LCA(i, j)] * 2;
// cout << i << " " << j << " " << dst << " " << A[i] + dst * B[i] << endl;
G[i].push_back({j, A[i] + dst * B[i]});
}
for(ll i = 1; i < n; i++) ndis[i] = 3e18;
ndis[0] = 0;
pq.push({0, 0});
while(pq.size())
{
int u = pq.top().first;
pq.pop();
if(vis[u]) continue;
vis[u] = 1;
for(auto t : G[u])
{
if(ndis[t.first] > ndis[u] + t.second)
{
ndis[t.first] = ndis[u] + t.second;
pq.push({t.first, t.second});
}
}
}
vector<ll> res;
for(int i = 1; i < n; i++) res.push_back(ndis[i]);
return res;
}
//signed main()
//{
// int n;
// scanf("%lld", &n);
// vector<int> A, B, U, V, W;
// for(int i = 1, x; i <= n; i++) scanf("%lld", &x), A.push_back(x);
// for(int i = 1, x; i <= n; i++) scanf("%lld", &x), B.push_back(x);
// for(int i = 1, x, y, z; i < n; i++) scanf("%lld%lld%lld", &x, &y, &z), U.push_back(x), V.push_back(y), W.push_back(z);
// vector<int> res = travel(A, B, U, V, W);
// for(int i = 0; i < n - 1; i++) printf("%lld ", res[i]);
// puts("");
// return 0;
//}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 0ms
memory: 14972kb
input:
2 684124582850 713748627948 74361 256955 0 1 661088
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 733283747618 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 3 lines
Test #2:
score: 7
Accepted
time: 0ms
memory: 10904kb
input:
3 251115773325 363097865287 358609487841 826785 213106 914768 0 1 851938 2 0 231697
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 955485332655 442679377470 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 4 lines
Test #3:
score: 7
Accepted
time: 2ms
memory: 11848kb
input:
3 489998888627 318672977903 70353752652 258347 458793 258657 2 1 156120 0 2 524840
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 665922861747 625589728107 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 4 lines
Test #4:
score: 7
Accepted
time: 2ms
memory: 12156kb
input:
3 737471938521 315388610250 818943569900 726908 666797 564862 0 1 460302 0 2 785280
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 1072069144737 1308298252761 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 4 lines
Test #5:
score: 7
Accepted
time: 2ms
memory: 11776kb
input:
4 201836820267 208957719162 992553400562 566050337171 243994 65303 590123 936951 1 0 259719 0 3 860376 3 2 513584
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 265206697953 537074816507 411763402011 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 5 lines
Test #6:
score: 7
Accepted
time: 2ms
memory: 11724kb
input:
4 440719935569 160237864481 704297665373 767778991240 451998 371509 46564 828427 1 0 861960 1 3 830699 2 3 185693
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 830324131649 1289731282865 1205798418251 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 5 lines
Test #7:
score: 7
Accepted
time: 0ms
memory: 12012kb
input:
5 148262899914 9382086008 622202345986 443806901161 213829280326 178155 503016 333953 572340 461148 0 3 453941 3 2 84057 4 0 171136 3 1 598794
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 335812903839 244109933604 229134758769 178751633994 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 6 lines
Test #8:
score: 7
Accepted
time: 0ms
memory: 14656kb
input:
5 391440982512 969252165920 333946610796 649830522527 902812044171 522045 996458 225429 545971 667483 0 1 701500 0 4 514779 2 1 435377 3 0 919439
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 757655550012 984941935977 871429515267 660178785567 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 6 lines
Test #9:
score: 7
Accepted
time: 2ms
memory: 11724kb
input:
17 315015458526 65513576283 829720084774 654640079244 561177336848 463903843105 496216524512 837433489064 92734412345 807145138979 250511786518 915329126804 373916658654 78276842047 121976569238 432447179015 519384539551 696133 642473 231377 987220 589587 337763 790202 785083 249580 108311 73808 892...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 430639669161 417840567823 403532946274 499079112962 498466070651 495984520010 499402357184 501387707132 498265325456 501233852966 474661031682 494612046266 411867746683 497598865088 499819422548 496976423075 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 18 lines
Test #10:
score: 7
Accepted
time: 0ms
memory: 11736kb
input:
20 764145449871 794297102632 450082553736 427358261877 587251097098 98567356955 15910789509 321286084089 25839798358 969219436118 975479420690 937908953492 410498404545 180209954689 302999489632 849828117651 171771046425 800442975277 295169929534 146003957886 828538 724406 733109 79844 665172 652593...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 1384833390877 871900130923 1446847771547 1245326093057 924349900475 1046486123707 1063981383357 864751505059 1159443240947 824076089025 1448542597977 1486181926466 1488465960086 1424780088987 1478403270966 1303312410681 1485431478966 1135576549657 1412080059777...
result:
ok 21 lines
Test #11:
score: 7
Accepted
time: 2ms
memory: 12680kb
input:
20 286866076510 666296858783 319893290745 436172872006 579306725182 388780143357 429085643976 163864091991 334402956892 573150791451 971047548996 924353133556 82495144441 364862686518 76783079529 74022380610 978776791995 17833817791 637808249822 150520055702 705613 111460 694926 702547 748042 671482...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 1345583882860 995125125260 815198043938 1295987956432 1034264067144 888082221934 1247814963646 1225117709350 631676569994 1289347270738 404306893004 1347095564962 373415155864 1441975557454 1167058795516 1091947224281 1373264198836 795244013911 1127743556434 se...
result:
ok 21 lines
Test #12:
score: 7
Accepted
time: 2ms
memory: 14624kb
input:
20 161996998737 15089127085 28063038428 574601167323 736141386895 762192247356 788118187801 956063872362 580983462657 839554694910 471536078792 781164874294 363054673222 809510755913 153755418459 78171544930 969593469579 864779185396 408120998971 610129629325 933618 563940 506188 824442 64614 396381...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 1870873819056 1340292002469 2180029603234 1667979150565 2084831816447 1131232525437 1898452835615 1742994070672 2139665843266 1042857179175 2148449164384 1856727805178 2077059488718 1931794896836 1753987714167 1864830429393 1705470391803 1529058594761 197326523...
result:
ok 21 lines
Test #13:
score: 7
Accepted
time: 2ms
memory: 11288kb
input:
20 443174843835 295023765677 175861678382 805210665445 724299682774 889923334441 967560897715 857729286838 7238459275 901083586058 887820756720 681912091803 886476957360 821901344613 222491154905 602669810322 953890359316 822857333786 674877086360 498973934687 505612 0 0 0 913180 49780 0 0 0 0 0 0 0...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 737522649521 561660971139 737522649521 737522649521 737522649521 737522649521 637744453675 737522649521 737522649521 737522649521 737522649521 737522649521 737522649521 737522649521 737522649521 737522649521 608216207263 737522649521 737522649521 secret: XBNN6R...
result:
ok 21 lines
Test #14:
score: 7
Accepted
time: 0ms
memory: 11272kb
input:
20 903941728884 384581140226 453502499061 225752209240 885300062423 504103937164 667092163600 460139456041 109118743857 207444296671 30492319139 345381827436 453966959387 438774451871 860637725773 554202343964 68114298125 781071441103 276250637196 155641220254 635683 100430 56855 0 0 0 0 0 0 142765 ...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 1792855089572 1792855089572 1792855089572 1792855089572 1792855089572 1792855089572 1332715633531 1792855089572 1792855089572 1792855089572 1792855089572 1792855089572 1792855089572 1792855089572 1792855089572 1792855089572 1792855089572 1792855089572 179285508...
result:
ok 21 lines
Test #15:
score: 7
Accepted
time: 0ms
memory: 14564kb
input:
20 1000000000000 7 1000000000000 13 1000000000000 1000000000000 13 5 1000000000000 1 1000000000000 1000000000000 12 6 1000000000000 3 16 18 10 7 1000000 999999 1000000 999997 1000000 1000000 999994 999993 1000000 999991 1000000 1000000 999988 999987 1000000 999985 999984 999983 999982 999981 0 1 691...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 1691757000000 2096049595714 2464529227234 2563764929539 3034748516584 3885772963503 4460798513342 4641761246599 4842046844590 5574182255313 6059278889404 6615402884243 7286465831403 7388442505695 8143381691358 8628101420456 8760501302040 9298906149020 934426333...
result:
ok 21 lines
Test #16:
score: 7
Accepted
time: 3ms
memory: 11424kb
input:
20 10 15 3 4 6 14 1000000000000 8 1000000000000 6 17 1000000000000 0 8 1000000000000 3 1 8 12 16 1000000 999999 999998 999997 999996 999995 1000000 999993 1000000 999991 999990 1000000 999988 999987 1000000 999985 999984 999983 999982 999981 0 1 197220 1 2 436230 2 3 822675 3 4 179287 4 5 533151 5 6...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 197220000010 633449563795 1456122918448 1635409380591 2168558247993 3065579762877 3926280459352 4087349331870 4728183845997 5358220175625 6266419093562 6968130076382 6985723865254 7299499786122 7859580504978 8093366998131 8775636081652 8926139523058 89838064850...
result:
ok 21 lines
Test #17:
score: 7
Accepted
time: 3ms
memory: 11636kb
input:
20 189782427733 285711699711 42839202308 323857876000 491102770223 681197470430 741563850085 770118022455 236662937828 460527070346 322304516149 407948067776 906756099567 581345187071 10531309090 96685590997 305996515557 289017611132 724839278560 441981934920 302755 557771 282205 475620 535221 82793...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 428459937493 646884046018 786290613318 982412880278 1253753718723 1534543706731 1557981114186 1577129287846 1819713270256 1848657061671 1871811459826 1890197068014 1919674253318 1934026950320 1960801118622 1977403784892 2009788771930 2014313798884 2035519586570...
result:
ok 21 lines
Test #18:
score: 7
Accepted
time: 2ms
memory: 12164kb
input:
19 20 4869939079 4869939079 1475687061 1475687061 236769056 120502350962 120502350962 4869939079 4869939079 236769056 696947 285 120502350962 12127756717 4061942829 35001226351 18770227218 120502350962 19715 22 1 6 22 1 1 1 3 14 1 1585 33 1009 14 3213 1 14 14 1 17 843518 0 13 773363 11 4 331406 2 0 ...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 6924732785 6923485436 6926848862 6925037261 6925431365 6924291344 6925858616 2051937220 6924502370 6924477974 6924043043 6924060575 6924508628 6925731629 6927300020 6924874217 6927263339 6925002536 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 20 lines
Test #19:
score: 7
Accepted
time: 0ms
memory: 12284kb
input:
20 22046 112845211637 272306351675 112845211637 2955509 7124 272306351675 64027867 595719023 2639297777 49993722591 49993722591 7124 2955509 373774 6 112845211637 360 112845211637 595719023 22772 17 4 1 17 39 8 240284 1 3 810 1 123 3 123 8 810 17 4 17 19 7 180627 18 3 992529 3 5 719911 10 9 467836 1...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 8894945676 8905143436 8886696844 8891169804 8892456132 8896006124 8888993412 8899307516 8886297524 8890040212 8897465804 8889166860 8896770972 8875081844 8871537806 8885825164 8879227404 8878756612 8887548396 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 21 lines
Test #20:
score: 7
Accepted
time: 2ms
memory: 11472kb
input:
20 7234739 60192 544422 1777110503 27883 243631 243631 15640571101 372138737 1 7234739 6282190524 1777110503 261389065797 15640571101 498987 243631 261389065797 261389065797 44277685886 15 10168 10168 7 52 1 164 15 3 15 7 1848 106 1 3 1848 1848 31 1 52 12 9 169781 9 14 222132 19 17 534510 18 1 48584...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 13842793 14083415 14476483 15368518 10078604 13682002 16069640 13326538 11194223 12711925 11907882 11364004 16235384 11416355 14442178 14732288 14055539 13356945 14590049 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 21 lines
Test #21:
score: 7
Accepted
time: 0ms
memory: 11124kb
input:
2 581307535501 194494107046 0 618074 1 0 748321
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 581307535501 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 3 lines
Test #22:
score: 7
Accepted
time: 0ms
memory: 12184kb
input:
3 317357548946 817037494642 528214670493 0 64902 893145 0 1 357981 1 2 51650
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 317357548946 317357548946 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
ok 4 lines
Test #23:
score: 7
Accepted
time: 0ms
memory: 11476kb
input:
20 286137165829 558481591168 246286874330 911296048340 206943928979 833902301678 630443861497 193595327826 811311131640 719010619000 144293442797 118799128728 485766833311 668841562 465636799002 325620667444 364206372275 34760004486 956952950350 99526176863 0 377748 929183 766805 131265 816232 69905...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 286137165829 secret: XBNN6R...
result:
ok 21 lines
Test #24:
score: 7
Accepted
time: 2ms
memory: 12780kb
input:
20 82163788626 769878692374 634172669528 307103728653 356345803186 883842875633 942490621740 931464527725 777069481299 984496783620 917129001578 859052618330 862400963887 877474997210 948597241660 967356250775 666322723616 931008804068 850613474811 762733726068 448734 7600 458862 310771 195137 432 1...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 1120791433067 933045570948 1120920076187 685236258054 236084935434 408886565292 704777277552 693121411902 777265767912 592010872086 422408266914 905999026566 838472188044 916287150984 541947414642 1120825893275 781034236044 874160451798 1104301312176 secret: XB...
result:
ok 21 lines
Test #25:
score: 7
Accepted
time: 0ms
memory: 12576kb
input:
20 454763477945 731519170596 100106306072 527835785299 586333054694 122404075974 179340225305 796659339924 910219062243 575223450053 674012377798 824682507041 676452173158 673138007110 915540143084 412056941211 782963066645 766909683853 365405785011 685446767739 101749 200151 272781 32539 475802 914...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 619559210815 561597994714 645888087302 662060683856 547938293213 587256040044 651552250634 636687535726 535045982670 571056378256 694788249706 550253489959 538847935804 488561341526 610054633227 597858794589 533363664704 496833331728 644141667466 secret: XBNN6R...
result:
ok 21 lines
Test #26:
score: 7
Accepted
time: 2ms
memory: 14740kb
input:
19 1000000000000 1000000000000 9 7 1000000000000 1000000000000 1000000000000 0 4 1000000000000 0 1000000000000 9 1000000000000 1000000000000 1000000000000 16 14 18 1000000 1000000 999991 999967 1000000 1000000 1000000 999971 999964 1000000 999955 1000000 999985 1000000 1000000 1000000 999949 999965 ...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 2246706779574 1000003000000 2845384451109 4298736269153 1342142000000 2845374451259 2246714779502 4298746268863 5401500837595 4994819071955 3826519963823 1342147000000 4994811072235 2129591833618 5155113461455 5155123461105 3826522963736 2129596833573 secret: X...
result:
ok 20 lines
Test #27:
score: 0
Wrong Answer
time: 0ms
memory: 12256kb
input:
20 1000000000000 1000000000000 8 15 1000000000000 14 1000000000000 1 2 1000000000000 8 0 1000000000000 19 1000000000000 19 2 1000000000000 1000000000000 1000000000000 1000000 1000000 999991 999984 1000000 999943 1000000 999954 999952 1000000 999994 999962 1000000 999991 1000000 999977 999971 1000000...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 5547039831468 1707689000000 2099243000000 2099237000000 5547040831430 4810335827284 4585104455132 4810337827208 4585102455190 1000007000000 3732846773424 1862897000000 1862904000000 3552746394342 2858701640801 3552748394324 2858693640873 3732841773469 170768700...
result:
wrong answer 2nd lines differ - expected: '5547034204329', found: '5547039831468'
Subtask #2:
score: 0
Time Limit Exceeded
Test #31:
score: 0
Time Limit Exceeded
input:
100000 746699125678 374834842799 250803643493 620187038832 454433387570 406226564003 897157438699 99473514061 734784419618 503968957100 363935477037 277126009840 52078020050 990757079812 847235285349 950784717285 271017141367 861087225700 996035427219 520682200664 282013988419 415183977876 882007771...
output:
Unauthorized output
result:
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Time Limit Exceeded
Test #69:
score: 0
Time Limit Exceeded
input:
100000 15175010 23519365 21177669 27079342 9089 16784452 29693960 23124925 17048604 10179491 12828214 24992902 8483134 2928073 23807522 7332137 17421520 28460746 1607282 13224363 11900728 11794692 11495061 4687109 23460275 7657982 27417256 16978162 7326803 23083826 24942987 16610314 12147303 2828271...
output:
Unauthorized output
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #94:
score: 0
Time Limit Exceeded
input:
99281 551670361798 568902251563 418071776626 697635341894 641578820039 117221079324 812766431051 425410617978 663769685693 282144284527 799662290178 749088952784 586626406385 122473825417 459510657357 871705247919 443707710712 735612808044 237919555727 829939639783 122127143240 616906466299 24431898...
output:
Unauthorized output
result:
Subtask #6:
score: 0
Skipped
Dependency #1:
0%