QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#164871 | #7118. Closing Time | Crysfly | 8 | 89ms | 51104kb | C++17 | 2.2kb | 2023-09-05 14:20:23 | 2024-04-28 07:29:12 |
Judging History
answer
// what is matter? never mind.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
#define i128 __int128
typedef int iint;
#define int long long
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 600005
#define inf 0x3f3f3f3f
int cardboard_box(vi a,vi b,int k){
int n=a.size();
For(i,0,n-1)a.pb(b[i]-a[i]);
priority_queue<pii,vector<pii>,greater<pii>>q1,q2;
For(i,0,n-1) q1.push(mkp(a[i],i)),q2.push(mkp(a[i]+a[i+n],i));
vi vis(n*2,0);
int res=0;
For(_,1,n*2){
while(q1.size() && vis[q1.top().se])q1.pop();
while(q2.size() && vis[q2.top().se])q2.pop();
if(res+q1.top().fi>k)return _-1;
int i=q1.top().se; q1.pop();
while(q1.size() && vis[q1.top().se])q1.pop();
if(_!=n*2 && q2.size() && a[i]+q1.top().fi>=q2.top().fi){
q1.push(mkp(a[i],i));
i=q2.top().se;
q2.pop();
}
if(i<n) q1.push(mkp(a[i+n],i+n));
res+=a[i],vis[i]=1;
}
return n*2;
}
vector<pii>e[maxn];
int dis1[maxn],dis2[maxn];
void dfs(int u,int pa,int*dis){
for(auto [v,w]:e[u]){
if(v==pa)continue;
dis[v]=dis[u]+w;
dfs(v,u,dis);
}
}
iint max_score(iint n,iint s,iint t,int k,vector<iint>U,vector<iint>V,vector<iint>W){
For(i,0,n-1) e[i].clear();
For(i,0,n-2) e[U[i]].pb(mkp(V[i],W[i])),e[V[i]].pb(mkp(U[i],W[i]));
dis1[s]=0,dfs(s,0,dis1);
dis2[t]=0,dfs(t,0,dis2);
int sum=0;
For(i,0,n-1){
bool on=(dis1[i]+dis2[i]==dis1[t]);
if(on)sum+=min(dis1[i],dis2[i]);
}
int res=0;
vi c;
For(i,0,n-1)c.pb(dis1[i]),c.pb(dis2[i]);
sort(c.begin(),c.end());
int now=0;
for(int x:c){
now+=x;
if(now>k)break;
++res;
}
if(sum<=k){
vi a,b;
For(i,0,n-1){
bool on=(dis1[i]+dis2[i]==dis1[t]);
if(on) a.pb(0),b.pb(max(dis1[i],dis2[i])-min(dis1[i],dis2[i]));
else a.pb(min(dis1[i],dis2[i])),b.pb(max(dis1[i],dis2[i]));
}
res=max(res,cardboard_box(a,b,k-sum));
}
return res;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 8
Accepted
Test #1:
score: 8
Accepted
time: 86ms
memory: 48552kb
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:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 451
result:
ok
Test #2:
score: 0
Accepted
time: 89ms
memory: 51104kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 200000 97133 170892 35489415917 114511 170892 730058 34783 114511 435023 34783 47301 562314 47301 162600 457629 44856 162600 365133 44856 133801 83016 117539 133801 124222 117539 128719 199821 77871 128719 703141 77871 133155 624331 7211 133155 138691 7211 ...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 650
result:
ok
Test #3:
score: 0
Accepted
time: 48ms
memory: 23112kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 200 1000 611 992 5736784 504 611 954658 504 936 219278 502 936 632439 393 502 177662 267 393 570266 267 291 941365 291 310 168052 310 765 253098 635 765 724932 274 635 842125 274 799 848645 39 799 433118 39 940 705598 553 940 564063 553 960 69665 917 960 6904...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 126 38 69 34 52 33 42 32 39 41 38 36 45 84 40 44 50 42 47 34 38 47 38 37 39 37 44 39 32 33 38 54 25 36 46 33 37 35 28 36 45 43 44 49 37 33 43 44 53 42 33 30 50 41 37 40 37 44 207 31 37 45 36 43 35 40 41 39 135 53 40 32 31 37 34 38 51 48 36 40 48 42 43 43 3...
result:
ok
Subtask #2:
score: 0
Wrong Answer
Test #4:
score: 9
Accepted
time: 0ms
memory: 20476kb
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 96
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 21864kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 47 20 22 25669694 0 1 291237 1 2 851987 2 3 421247 3 4 962919 4 5 643085 5 6 224951 6 7 756890 7 8 147295 8 9 625823 9 10 736374 10 11 290526 11 12 335466 12 13 539086 13 14 957449 14 15 423408 15 16 932444 16 17 356032 17 18 307118 18 19 94279 19 20 989546...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 26
result:
ok
Test #6:
score: 0
Accepted
time: 2ms
memory: 20720kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 46 6 34 355277954 0 1 574359 1 2 58362 2 3 778155 3 4 538832 4 5 128903 5 6 79774 6 7 715282 7 8 259924 8 9 640303 9 10 361135 10 11 506866 11 12 527045 12 13 946672 13 14 620381 14 15 701743 15 16 766266 16 17 524732 17 18 340089 18 19 630172 19 20 357712 ...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 74
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 20332kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 45 14 44 70669 0 1 266130 1 2 372315 2 3 965349 3 4 119493 4 5 190522 5 6 506822 6 7 45330 7 8 423189 8 9 748532 9 10 653554 10 11 102552 11 12 90431 12 13 843259 13 14 422626 14 15 35334 15 16 1 16 17 1 17 18 1 18 19 1 19 20 1 20 21 1 21 22 1 22 23 1 23 24...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 4
result:
ok
Test #8:
score: 0
Accepted
time: 4ms
memory: 20804kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 50 0 49 332340134 0 1 987193 1 2 950856 2 3 893737 3 4 870689 4 5 810192 5 6 790242 6 7 744052 7 8 714922 8 9 677074 9 10 630082 10 11 599644 11 12 528415 12 13 491648 13 14 479486 14 15 439182 15 16 371085 16 17 357776 17 18 308161 18 19 254481 19 20 20430...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 44
result:
ok
Test #9:
score: 0
Accepted
time: 4ms
memory: 21460kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 50 0 49 329827838 0 1 972981 1 2 953594 2 3 908629 3 4 849675 4 5 808354 5 6 782643 6 7 759387 7 8 698618 8 9 650896 9 10 639153 10 11 591828 11 12 532588 12 13 503214 13 14 447660 14 15 403224 15 16 380834 16 17 327127 17 18 300115 18 19 244025 19 20 23362...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 44
result:
ok
Test #10:
score: -9
Wrong Answer
time: 4ms
memory: 21480kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 3 0 1 1 0 1 1 1 2 1
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 4
result:
wrong answer 1st lines differ - on the 1st token, expected: '3', found: '4'
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: 0ms
memory: 21892kb
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: 3ms
memory: 22032kb
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: 4ms
memory: 20788kb
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: 4ms
memory: 20080kb
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: -9
Wrong Answer
time: 4ms
memory: 21728kb
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 33
result:
wrong answer 1st lines differ - on the 1st token, expected: '28', found: '33'
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:
100%
Accepted
Dependency #2:
0%