QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#164605#7118. Closing Timeunputdownable0 102ms37944kbC++172.4kb2023-09-05 11:03:512024-04-28 07:27:36

Judging History

你现在查看的是最新测评结果

  • [2024-04-28 07:27:36]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:102ms
  • 内存:37944kb
  • [2023-09-05 11:03:51]
  • 评测
  • 测评结果:0
  • 用时:114ms
  • 内存:36656kb
  • [2023-09-05 11:03:51]
  • 提交

answer

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#include "closing.h"
#include <bits/stdc++.h>
// #define int long long
#define i64 long long
#define pii pair <i64, i64> 
using namespace std;
vector <pii> E[200005];
i64 depx[200005],depy[200005];
i64 sig[400005],cnt1,cnt2;
pii val[200005];
i64 vvv[400005];
inline void dfs(int x,int f,i64*dep) {
    for(pii e : E[x]) {
        if(e.first==f) continue;
        dep[e.first]=dep[x]+e.second;
        dfs(e.first,x,dep);
    }
} 
inline void check(int&R,i64&sum,i64 lim) { if(lim<0) return R=-1000000,void(); while(sum>lim) sum-=sig[R--]; }
int max_score(int n, int x, int y,i64 k, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    for(int i=0; i<n; ++i) E[i].clear(); cnt1=cnt2=0; int k0=k;
    int m=U.size();
    for(int i=0; i<m; ++i) E[U[i]].emplace_back(V[i],W[i]);
    for(int i=0; i<m; ++i) E[V[i]].emplace_back(U[i],W[i]);
    dfs(x,-1,depx);
    dfs(y,-1,depy);
    // for(int i=0; i<n; ++i) cerr<<depx[i]<<' '; cerr<<endl;
    // for(int i=0; i<n; ++i) cerr<<depy[i]<<' '; cerr<<endl;
    int cnt=0;
    for(int i=0,a,b; i<n; ++i) {
        vvv[i+1]=depx[i];
        vvv[i+n+1]=depy[i];
        if(depx[i]+depy[i]==depx[y]) {
            k-=min(depx[i],depy[i]);
            sig[++cnt1]=max(depx[i],depy[i]);
            ++cnt;
            continue;
        }
        if(depx[i]>depy[i]) a=depy[i],b=depx[i]-a; 
        else                a=depx[i],b=depy[i]-a;
        if(a<b) sig[++cnt1]=a,sig[++cnt1]=b;
        else    val[++cnt2]=(pii){a+b,a};
    }
    sort(val+1,val+cnt2+1);
    sort(sig+1,sig+cnt1+1);
    sort(vvv+1,vvv+2*n+1); vvv[2*n+1]=k0+1;
    int p=0; i64 s1=0; 
    while(s1+vvv[p+1]<=k0) s1+=vvv[++p];
    int Ans=p;
    // cerr<<Ans<<"----------"<<endl;
    // for(int i=1; i<=cnt1; ++i) cerr<<sig[i]<<' '; cerr<<endl;
    // for(int i=1; i<=cnt2; ++i) cerr<<val[i].first<<' '<<val[i].second<<'|'; cerr<<endl;
    int R=0; i64 sum=0; sig[cnt1+1]=k+1;
    while(sum+sig[R+1]<=k) sum+=sig[++R];
    // cerr<<R<<' '<<sum<<endl;
    if(k>=0) Ans=max(Ans,R+cnt);
    // cerr<<"------------------"<<endl;
    if(k>=0) for(int i=1; i<=cnt2; ++i) {
        check(R,sum,k-val[i].second),Ans=max(Ans,2*i+R+cnt-1);
        check(R,sum,k-=val[i].first),Ans=max(Ans,2*i+R+cnt);
    } 
    return Ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 102ms
memory: 37944kb

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
0

result:

wrong answer 1st lines differ - on the 1st token, expected: '451', found: '0'

Subtask #2:

score: 0
Wrong Answer

Test #4:

score: 9
Accepted
time: 0ms
memory: 14200kb

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: 9
Accepted
time: 2ms
memory: 14300kb

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
Wrong Answer
time: 2ms
memory: 12584kb

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
66

result:

wrong answer 1st lines differ - on the 1st token, expected: '74', found: '66'

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: 0
Wrong Answer
time: 3ms
memory: 14288kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
4 0 1 9
0 2 2
1 2 3
2 3 3

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
5

result:

wrong answer 1st lines differ - on the 1st token, expected: '6', found: '5'

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%