QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#785207 | #6660. 택시 여행 | chrhaa | 0 | 1033ms | 61276kb | C++14 | 2.3kb | 2024-11-26 17:09:43 | 2024-11-26 17:09:52 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
const int N=100005,M=N*25;
#define ll long long
const ll INF=9000000000000000007ll,U=1000000000000ll;
struct edge{
int v,w;
};
struct line{
ll k,b;
inline ll operator()(ll x)const{
return k*x+b;
}
};
int n,up[N],sz[N],c[N],h[N];
bool vis[N];
ll a[N],b[N],ds[25][N];
vector<edge> g[N];
void dfs1(int x,int fa,int k,ll d){
sz[x]=1;
ds[k][x]=d;
for(edge e:g[x]) if(e.v!=fa&&!vis[e.v]){
dfs1(e.v,x,k,d+e.w);
sz[x]+=sz[e.v];
}
}
void dfs2(int x,int fa,int tot,int &rt){
c[x]=tot-sz[x];
for(edge e:g[x]) if(e.v!=fa&&!vis[e.v]){
dfs2(e.v,x,tot,rt);
c[x]=max(c[x],sz[e.v]);
}
if(!rt||c[x]<c[rt]) rt=x;
}
void build(int x,int k){
h[x]=k;
vis[x]=true;
dfs1(x,0,k,0);
for(edge e:g[x]) if(!vis[e.v]){
int rt=0;
dfs2(e.v,x,sz[e.v],rt);
up[rt]=x;
build(rt,k+1);
}
}
int c1,c2;
int w[M],ls[M],rs[M],rt[N],id[N];
line f[M];
#define mid (l+r>>1)
void update(int &x,ll l,ll r,int v){
if(!x){
x=++c1;
w[x]=v;
return ;
}
if(f[w[x]](mid)>f[v](mid)) swap(w[x],v);
if(l<r){
if(f[w[x]](l)>f[v](l)) update(ls[x],l,mid,v);
if(f[w[x]](r)>f[v](r)) update(rs[x],mid+1,r,v);
}
}
ll query(int x,ll l,ll r,ll p){
if(!p) return INF;
if(l<r){
if(p<=mid) return min(f[w[x]](p),query(ls[x],l,mid,p));
else return min(f[w[x]](p),query(rs[x],mid+1,r,p));
}else return f[w[x]](p);
}
void update(int x,ll v){
for(int i=x;i;i=up[i]){
f[++c2]={b[x],v+b[x]*ds[h[i]][x]};
update(rt[i],0,U,c2);
}
}
ll query(int x){
ll res=INF;
for(int i=x;i;i=up[i])
res=min(res,query(rt[i],0,U,ds[h[i]][x]));
return res;
}
vector<ll> travel(vector<ll> A,vector<int> B,vector<int> U,vector<int> V,vector<int> W){
int i;
vector<ll> ans;
n=A.size();
for(i=1;i<=n;i++) a[i]=A[i-1],b[i]=B[i-1],id[i]=i;
for(i=0;i<n-1;i++){
g[U[i]+1].push_back({V[i]+1,W[i]});
g[V[i]+1].push_back({U[i]+1,W[i]});
}
build(1,0);
f[0]={0,INF};
update(1,a[1]);
sort(id+1,id+n+1,[](int x,int y){return b[x]>b[y];});
for(i=1;i<=n;i++) if(b[i]<b[1])
update(id[i],query(id[i])+a[id[i]]);
for(i=2;i<=n;i++) ans.push_back(query(i));
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 0ms
memory: 18120kb
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: 2ms
memory: 16068kb
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: 0ms
memory: 16336kb
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: 16092kb
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: 0ms
memory: 18124kb
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: 0ms
memory: 18368kb
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: 2ms
memory: 18080kb
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: 16084kb
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: 3ms
memory: 18156kb
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: 0
Wrong Answer
time: 2ms
memory: 18132kb
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 1486706777166 1303312410681 1485431478966 1135576549657 1412080059777...
result:
wrong answer 16th lines differ - expected: '1478403270966', found: '1486706777166'
Subtask #2:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 1026ms
memory: 61276kb
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:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 1148030742334 1636760433058 2131282232650 2353514637869 2672707119337 3030852161530 2948215735597 3003888852169 3054019822989 3117708941277 3168979051095 3626206588963 3269286229765 3273106480907 3287227043365 3335909595067 3361857042147 3364657567217 338173015...
result:
wrong answer 7th lines differ - expected: '2763307672337', found: '3030852161530'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Wrong Answer
Test #69:
score: 0
Wrong Answer
time: 166ms
memory: 32028kb
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:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 16817058 ...
result:
wrong answer 2nd lines differ - expected: '16705757', found: '16817058'
Subtask #5:
score: 0
Wrong Answer
Test #94:
score: 29
Accepted
time: 235ms
memory: 39796kb
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:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 598598746654 5...
result:
ok 99282 lines
Test #95:
score: 29
Accepted
time: 436ms
memory: 43856kb
input:
100000 762048253398 544847923340 274220772253 709492519024 93107863549 990677171512 878434244170 777350365410 575870270443 928311965336 349432073756 948390047110 470116186153 495432094032 154258868766 719518553291 580490378718 661863092617 453262793865 191963964294 783054160061 953488248260 99347544...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 764692690700 7...
result:
ok 100001 lines
Test #96:
score: 29
Accepted
time: 639ms
memory: 49024kb
input:
94281 131658172659 39811340435 707706551378 488270943344 316094085836 187344969354 859815132521 257455926058 398461451565 636824600504 968337263051 657378201148 381422070176 704193397218 215057852195 143696981366 245020143023 544889243460 19853724068 381481133078 270430609102 661194702920 9327187294...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 513000148750 5...
result:
ok 94282 lines
Test #97:
score: 29
Accepted
time: 946ms
memory: 55564kb
input:
98013 219274952148 967847968840 993514312942 249215975388 377408063086 409277664478 513688960578 870781013811 5313297905 381786485971 932846528432 355907313844 568982393234 615505455703 556586556337 580222086746 513159753737 447726612888 849878699364 872433100635 459323693660 591180592643 9928561494...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 397148182990 3...
result:
ok 98014 lines
Test #98:
score: 29
Accepted
time: 1033ms
memory: 59944kb
input:
100000 793084247557 856407004352 124019471672 758580217324 391555277659 748332370727 824874943785 454763878407 172204390651 200693040566 241971294452 420325832639 276303819033 490288760803 518648078771 428578774460 552156115324 270613111346 564717918818 914239531441 363337438048 359070665547 4058804...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 1347236750935 134723675...
result:
ok 100001 lines
Test #99:
score: 29
Accepted
time: 243ms
memory: 37784kb
input:
100000 186878865231 744364257898 407647146449 178229661742 142659258467 867497410431 566102005411 743741769325 966116499644 374901320569 460953729268 166466122244 599772360298 778326103398 923306353276 541041861259 456336739387 460166266166 277100384431 124520154825 91585321170 808947541069 49305171...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 199304498331 1...
result:
ok 100001 lines
Test #100:
score: 29
Accepted
time: 429ms
memory: 47808kb
input:
100000 701868643554 195683029255 191726673386 60711384096 246001015103 235534486089 867356428487 679339700226 266886499198 165357218261 892542762609 49935133853 78861964822 648163497576 458431664651 259806246005 944174571815 556122544299 640157239681 239448194098 270814892412 832337696089 1764039054...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 786865661638 7...
result:
ok 100001 lines
Test #101:
score: 29
Accepted
time: 697ms
memory: 53696kb
input:
100000 438739740535 795928502119 872639081700 294554691174 226473457726 440783927287 150198126950 915922926283 516380773321 487345449103 452763239700 807838622400 226343342171 740475572228 441100842060 488895978441 476807788781 262972018901 384528067019 387913043837 839407743741 462422811237 7784206...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 865668346868 8...
result:
ok 100001 lines
Test #102:
score: 0
Wrong Answer
time: 962ms
memory: 56052kb
input:
100000 694640698205 388240595320 449732757362 105097389837 586358675392 161335658819 425877820487 740670399542 410740826602 978399832816 430048583471 246136844716 701889327015 378563563646 252509017658 388896850779 573768686022 926987324089 60052463883 832676326751 23069584465 214255472478 621178722...
output:
secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 4111303149419 411130314...
result:
wrong answer 21225th lines differ - expected: '4071485744202', found: '4111303149419'
Subtask #6:
score: 0
Skipped
Dependency #1:
0%