QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#786128 | #6660. 택시 여행 | int_R | 0 | 416ms | 119172kb | C++14 | 2.8kb | 2024-11-26 20:23:36 | 2024-11-26 20:23:41 |
Judging History
answer
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int,int> Pair;
typedef pair<ll,ll> Pairl;
const int MAXN=1e5+10;
const ll INF=4e18;
int n,b[MAXN],fa[MAXN],pos[MAXN];
ll a[MAXN];
vector <Pair> v[MAXN];
unordered_map <int,unordered_map<int,int>> dis;
namespace tree
{
int MIN,R,S,siz[MAXN];
bool vis[MAXN];
void dfs(int x,int fa=0)
{
int MAX=0;siz[x]=1;
for(auto now:v[x])
{
int y=now.first;
if(y==fa||vis[y]) continue;
dfs(y,x),siz[x]+=siz[y];
MAX=max(MAX,siz[y]);
}
MAX=max(MAX,S-siz[x]);
if(MAX<MIN) MIN=MAX,R=x;
}
void calc(int x,int fa=0,ll D=0)
{
dis[R][x]=D;
for(auto now:v[x])
{
int y=now.first;
if(y==fa||vis[y]) continue;
calc(y,x,D+now.second);
}
}
void work(int x)
{
vis[x]=true;calc(x);
for(auto now:v[x])
{
int y=now.first;
if(vis[y]) continue;
MIN=MAXN,S=siz[y],dfs(y);
fa[R]=x,dfs(R),work(R);
}
}
void init()
{MIN=MAXN,S=n,dfs(1),dfs(R),work(R);}
}
inline bool cmp(int x,int y)
{return b[x]>b[y];}
struct node
{
vector <Pairl> f;
inline ll F(Pairl f,int x)
{return f.first*x+f.second;}
inline ll qry(ll x)
{
if(f.empty()) return INF;
int l=0,r=f.size()-1;
while(l<r)
{
int mid=(l+r)>>1;
ll suma=F(f[mid],x);
ll sumb=F(f[mid+1],x);
(suma>sumb)?l=mid+1:r=mid;
}
return F(f[l],x);
}
inline void upd(ll k,ll B)
{
if(!f.empty()&&f.back().second>=B)
f.pop_back();
if(f.empty()||f.back().first!=B)
f.emplace_back(k,B);
}
}t[MAXN];
inline ll qry(int x)
{
ll D=INF;
for(int p=x;p;p=fa[p])
D=min(D,t[p].qry(dis[p][x]));
return D;
}
inline void upd(int x,ll D)
{
for(int p=x;p;p=fa[p])
t[p].upd(b[x],D+a[x]+1ll*b[x]*dis[p][x]);
}
vecll travel(vecll A,vecint B,vecint U,vecint V,vecint W)
{
n=A.size();
for(int i=0;i<n;++i)
a[i+1]=A[i],b[i+1]=B[i];
for(int i=0;i<n-1;++i)
v[U[i]+1].emplace_back(V[i]+1,W[i]),
v[V[i]+1].emplace_back(U[i]+1,W[i]);
tree::init();
for(int i=1;i<=n;++i) pos[i]=i;
sort(pos+1,pos+n+1,cmp);
upd(1,0);
for(int i=1;i<=n;++i)
{
if(b[pos[i]]>=b[1]) continue;
upd(pos[i],qry(pos[i]));
}
vecll C;
for(int i=2;i<=n;++i)
C.push_back(qry(i));
return C;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 2ms
memory: 10868kb
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: 9260kb
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: 9244kb
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: 11112kb
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: 1ms
memory: 9988kb
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: 1ms
memory: 9416kb
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: 9876kb
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: 1ms
memory: 9624kb
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: 0
Wrong Answer
time: 0ms
memory: 9324kb
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 854701616505 811025535952 634227941809 877731088411 501387707132 796723483467 501233852966 474661031682 536446316097 411867746683 749241643803 907444829383 704895883304 secret: XBNN6R0Jnospxlfz11GWxd4ldkzb0I
result:
wrong answer 5th lines differ - expected: '499079112962', found: '854701616505'
Subtask #2:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 416ms
memory: 119172kb
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 -244496226837474671 -244496238476864147 -244496250254196155 -244496256864457007 -244496268402888275 -244496271677991275 -244496283804881219 -244496294497701227 -244496304126072707 -244496316358480739 -244496326205640191 -244496334852873383 -244496345471071571 -...
result:
wrong answer 2nd lines differ - expected: '1148030742334', found: '-244496226837474671'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Wrong Answer
Test #69:
score: 0
Wrong Answer
time: 156ms
memory: 56612kb
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 70162408 74364716 74443173 63752036 75926185 67643011 88151266 97330744 83451140 66595851 80072399 66642637 74369439 72273739 66642637 66642637 69871260 79988941 64325905 66642637 87706986 75107009 72199871 66642637 66642637 87462704 56639269 80412078 66642637 ...
result:
wrong answer 2nd lines differ - expected: '16705757', found: '70162408'
Subtask #5:
score: 0
Wrong Answer
Test #94:
score: 0
Wrong Answer
time: 214ms
memory: 60364kb
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 3240619687523 3240619687523 3199937996153 3240619687523 3013165061752 3091534992113 3240619687523 2976717376848 3014982836587 3209494433626 3240619687523 3206153290484 3177611324287 3240619687523 3240619687523 3124437150173 3209494433626 3170814266334 323530995...
result:
wrong answer 2nd lines differ - expected: '598598746654', found: '3240619687523'
Subtask #6:
score: 0
Skipped
Dependency #1:
0%