QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#785276 | #6660. 택시 여행 | chrhaa | 0 | 133ms | 61656kb | C++14 | 2.3kb | 2024-11-26 17:23:05 | 2024-11-26 17:23:05 |
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*40;
#define ll long long
const ll INF=900000000000000007ll,U=100000000000ll;
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);
rt=e.v;
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(!x) 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;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 3ms
memory: 18104kb
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: 3ms
memory: 16104kb
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: 16088kb
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: 0ms
memory: 14056kb
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: 18120kb
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: 16356kb
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: 16080kb
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: 2ms
memory: 16324kb
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: 0ms
memory: 16348kb
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: 2ms
memory: 18204kb
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: 0
Wrong Answer
time: 2ms
memory: 18116kb
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 1677113496407 995125125260 815198043938 1570646373289 1034264067144 888082221934 1467233848848 1418509859972 631676569994 1556390873850 404306893004 1507260451886 373415155864 1884036625496 1293875318943 1091947224281 1736534578363 795244013911 1209477653626 se...
result:
wrong answer 2nd lines differ - expected: '1345583882860', found: '1677113496407'
Subtask #2:
score: 0
Runtime Error
Test #31:
score: 0
Runtime Error
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
Wrong Answer
Test #69:
score: 0
Wrong Answer
time: 63ms
memory: 31492kb
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
Runtime Error
Test #94:
score: 29
Accepted
time: 55ms
memory: 35928kb
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: 85ms
memory: 46072kb
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: 133ms
memory: 61656kb
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: 0
Runtime Error
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:
Unauthorized output
result:
Subtask #6:
score: 0
Skipped
Dependency #1:
0%