QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#235944 | #7118. Closing Time | 275307894a | 0 | 2ms | 11704kb | C++14 | 2.2kb | 2023-11-03 13:46:51 | 2024-04-28 07:57:52 |
Judging History
answer
#include "closing.h"
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e5+5,M=5e5+5,K=(1<<25)+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int n;ll k;vector<pii> S[N];
ll d1[N],d2[N];
void Make(int x,int La,ll *d){
cerr<<x<<' '<<La<<' '<<d[x]<<'\n';
for(auto i:S[x]) if(i.fi^La) d[i.fi]=d[x]+i.se,Make(i.fi,x,d);
}
int max_score(int nn,int X,int Y,ll kk,vector<int> U,vector<int> V,vector<int> W){
int i,j;n=nn;k=kk;for(i=0;i<n;i++) S[i].clear();
for(int i=0;i<n-1;i++) S[U[i]].emplace_back(V[i],W[i]),S[V[i]].emplace_back(U[i],W[i]);
d1[X]=d2[Y]=0;Make(X,-1,d1);Make(Y,-1,d2);
k*=2;
for(int i=0;i<n;i++) d1[i]*=2,d2[i]*=2,cerr<<d1[i]<<' '<<d2[i]<<'\n';
priority_queue<pair<ll,int> > q;
int ans=0, tot=0;
for(i=0;i<n;i++) q.emplace(-d1[i],0),q.emplace(-d2[i],0);
ll m=k;
while(!q.empty()){
auto p=q.top();q.pop();
p.fi*=-1;
if(m>=p.fi) m-=p.fi,tot++;
else break;
}
ans=max(ans,tot);
while(!q.empty()) q.pop();
tot=0;m=k;
for(i=0;i<n;i++) {
if(d1[i]>d2[i]) swap(d1[i],d2[i]);
}
ll Le=d1[X]+d2[X];
for(i=0;i<n;i++){
if(d1[i]+d2[i]==Le){
tot++;m-=min(d1[i],d2[i]);
q.emplace(-abs(d1[i]-d2[i]),0);
}else {
d2[i]-=d1[i];
if(d1[i]<=d2[i]) q.emplace(-d1[i],0),q.emplace(-d2[i],0);
else q.emplace(-(d1[i]+d2[i])/2,-i);
}
}
ll mm=0;
while(!q.empty()){
auto p=q.top();q.pop();p.fi*=-1;p.se*=-1;
if(m<p.fi) break;
// cerr<<tot<<' '<<m<<' '<<p.fi<<' '<<p.se<<'\n';
if(!p.se) {m-=p.fi;mm=max(mm,p.fi);tot++;continue;}
if(m>=d1[p.se]+d2[p.se]) {m-=d1[p.se]+d2[p.se];tot+=2;continue;}
if(m+mm>=d1[p.se]+d2[p.se]) {
tot++;break;
}
q.emplace(-d1[p.se],0);
}
cerr<<tot<<'\n';
if(m>=0) ans=max(ans,tot);
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 200000 31011 61157 8517583098 31011 129396 964383 1655 129396 331139 1655 191487 566483 110385 191487 865248 43212 110385 542661 43212 81682 13766 81682 91774 546589 91774 124706 780638 124706 175650 118706 10421 175650 615314 10421 151953 436270 140430 151...
output:
result:
Subtask #2:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 10884kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 50 23 25 382806473 0 1 375710 1 2 898637 2 3 10402 3 4 536577 4 5 385023 5 6 71075 6 7 543368 7 8 301497 8 9 174394 9 10 711312 10 11 923006 11 12 675532 12 13 838667 13 14 565729 14 15 979816 15 16 862618 16 17 576015 17 18 177751 18 19 306989 19 20 881492...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 97
result:
wrong answer 1st lines differ - on the 1st token, expected: '96', found: '97'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Wrong Answer
Test #36:
score: 9
Accepted
time: 2ms
memory: 11704kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 4 0 1 9 0 2 2 1 2 3 2 3 3
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 6
result:
ok
Test #37:
score: 0
Accepted
time: 2ms
memory: 9744kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 4 0 1 8 0 2 2 1 2 3 2 3 100
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 5
result:
ok
Test #38:
score: 0
Accepted
time: 0ms
memory: 11328kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 8 0 4 84 0 1 1 1 2 29 2 3 29 3 4 1 4 5 20 2 6 20 3 7 1
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 9
result:
ok
Test #39:
score: 0
Accepted
time: 0ms
memory: 10564kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 18 14 15 221112 8 10 15984 3 8 2664 6 10 5328 9 10 13320 5 10 23976 1 10 13320 3 4 5328 3 7 26640 3 11 23976 4 15 23976 6 17 18648 12 17 5328 11 13 13320 0 11 7992 15 16 5328 2 16 5328 13 14 2664
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 14
result:
ok
Test #40:
score: 0
Accepted
time: 0ms
memory: 10084kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 19 3 9 11232111 13 14 174955 0 13 69982 10 14 209946 14 15 209946 12 14 104973 0 11 314919 0 3 314919 0 7 139964 5 10 209946 10 16 69982 4 10 104973 9 11 279928 9 17 349910 1 4 104973 3 18 209946 6 18 174955 7 8 314919 2 7 104973
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 28
result:
ok
Test #41:
score: 0
Accepted
time: 0ms
memory: 9928kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 15 5 7 155966 1 4 964448 5 11 996819 9 10 330180 5 6 987448 11 12 704605 0 5 155967 8 14 596631 10 11 923917 0 14 560902 4 13 49411 1 7 856694 1 12 755799 2 14 488208 3 13 990480
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 2
result:
ok
Test #42:
score: 0
Accepted
time: 2ms
memory: 11180kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 20 4 7 40726445 15 18 841797 9 16 909512 0 7 39919 8 19 78725 6 17 661904 7 14 426400 17 18 664669 7 13 917960 4 14 821652 4 11 274656 1 12 937782 10 19 129031 12 13 504353 5 11 502915 3 8 264525 2 19 358409 12 18 578659 16 19 696491 3 17 175157
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 30
result:
ok
Test #43:
score: 0
Accepted
time: 2ms
memory: 10436kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 19 1 8 758761123780644886 3 18 947982 12 13 415218 3 15 890432 11 17 808801 2 8 726510 7 12 752493 8 17 328133 6 7 465830 8 14 126540 9 18 443041 1 7 605214 4 11 243452 9 10 106626 3 7 498126 1 4 39081 0 2 861168 5 15 69635 3 16 223395
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 38
result:
ok
Test #44:
score: 0
Accepted
time: 2ms
memory: 11248kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 18 4 10 8410500 14 16 912609 2 8 546082 2 12 129063 1 17 454917 15 17 85372 1 11 862697 4 11 428830 7 9 860609 8 10 119165 6 11 143393 14 17 789886 13 15 216341 4 5 56300 12 13 718046 0 7 354300 9 15 142154 1 3 310843
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 11
result:
ok
Test #45:
score: -9
Wrong Answer
time: 0ms
memory: 11448kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 18 14 15 23103649 0 6 382587 2 4 23201 2 3 58517 0 10 982598 0 17 283539 13 14 944945 4 6 576463 8 14 941541 7 16 566937 1 11 185982 3 9 360540 1 5 441702 4 16 808047 3 14 154737 3 15 344378 9 11 631318 7 12 552451
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 35
result:
wrong answer 1st lines differ - on the 1st token, expected: '36', found: '35'
Subtask #6:
score: 0
Skipped
Dependency #2:
0%
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #4:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%