QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#155717#7118. Closing Timebulijiojiodibuliduo#Compile Error//C++171.9kb2023-09-02 02:24:462024-04-28 06:46:40

Judging History

This is the latest submission verdict.

  • [2024-04-28 06:46:40]
  • 管理员手动重测本题所有提交记录
  • [2023-09-02 02:24:46]
  • Judged
  • [2023-09-02 02:24:46]
  • Submitted

answer

int max_score(int n, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    vector<vector<pair<int,int>>> e(n);
    rep(i,0,n-1) {
        int u=U[i],v=V[i],w=W[i];
        e[u].pb(mp(v,w));
        e[v].pb(mp(u,w));
    }
    vector<ll> dis1(n),dis2(n);
    function<void(int,int,ll,vector<ll>&)> dfs=[&](int u,int f,ll dep,vector<ll>& dis) {
        dis[u]=dep;
        //printf("??? %d\n",u);
        for (auto [v,w]:e[u]) if (v!=f) {
            dfs(v,u,dep+w,dis);
        }
    };
    dfs(X,0,0ll,dis1);
    dfs(Y,0,0ll,dis2);
    map<ll,vector<ll>> grp;
    vector<ll> w;
    for (int i=0;i<n;i++) {
        w.pb(min(dis1[i],dis2[i]));
        //grp[abs(dis1[i]-dis2[i])].pb(min(dis1[i],dis2[i]));
        //printf("!!! %d %lld %lld\n",i,dis1[i],dis2[i]);
    }
    sort(all(w));
    int ans1=0;
    ll s=0;
    for (auto x:w) {
        s+=x;
        if (s<=K) ans1++;
    }
    for (int i=0;i<n;i++) if (dis1[i]+dis2[i]==dis1[Y]) {
        K-=min(dis1[i],dis2[i]);
        grp[abs(dis1[i]-dis2[i])].pb(0);
    } else {
        grp[abs(dis1[i]-dis2[i])].pb(min(dis1[i],dis2[i]));        
    }
    vector<ll> ret{0ll};
    for (auto [d,vc]:grp) {
        sort(all(vc));
        vector<ll> q1,q2,dp;
        for (auto x:vc) if (x<=d) q1.pb(x); else q2.pb(x);
        ll s=0; dp.pb(0);
        for (auto x:q1) { s+=x; dp.pb(s); }
        rep(i,0,SZ(q1)) { s+=d; dp.pb(s); }
        for (auto x:q2) {
            s+=x; dp.pb(s);
            s+=d; dp.pb(s);
        }
        //printf("dp: ");
        //for (auto x:dp) printf("%lld ",x); puts("");
        vector<ll> tmp(SZ(ret)+SZ(dp)-1,1ll<<60);
        rep(p1,0,SZ(ret)) rep(p2,0,SZ(dp)) tmp[p1+p2]=min(tmp[p1+p2],ret[p1]+dp[p2]);
        ret=tmp;
    }
    //for (auto x:ret) printf("%lld ",x); puts("");
    int ans2=0;
    rep(i,1,SZ(ret)) if (ret[i]<=K) ans2++;
    return max(ans1,ans2);
}

Details

answer.code:2:15: error: ‘std::vector’ has not been declared
    2 |               std::vector<int> U, std::vector<int> V, std::vector<int> W)
      |               ^~~
answer.code:2:26: error: expected ‘,’ or ‘...’ before ‘<’ token
    2 |               std::vector<int> U, std::vector<int> V, std::vector<int> W)
      |                          ^
answer.code: In function ‘int max_score(int, int, int, long long int, int)’:
answer.code:4:5: error: ‘vector’ was not declared in this scope
    4 |     vector<vector<pair<int,int>>> e(n);
      |     ^~~~~~
answer.code:4:19: error: ‘pair’ was not declared in this scope
    4 |     vector<vector<pair<int,int>>> e(n);
      |                   ^~~~
answer.code:4:24: error: expected primary-expression before ‘int’
    4 |     vector<vector<pair<int,int>>> e(n);
      |                        ^~~
answer.code:5:9: error: ‘i’ was not declared in this scope
    5 |     rep(i,0,n-1) {
      |         ^
answer.code:5:5: error: ‘rep’ was not declared in this scope
    5 |     rep(i,0,n-1) {
      |     ^~~
answer.code:10:12: error: ‘ll’ was not declared in this scope
   10 |     vector<ll> dis1(n),dis2(n);
      |            ^~
answer.code:10:16: error: ‘dis1’ was not declared in this scope
   10 |     vector<ll> dis1(n),dis2(n);
      |                ^~~~
answer.code:10:24: error: ‘dis2’ was not declared in this scope
   10 |     vector<ll> dis1(n),dis2(n);
      |                        ^~~~
answer.code:11:5: error: ‘function’ was not declared in this scope; did you mean ‘union’?
   11 |     function<void(int,int,ll,vector<ll>&)> dfs=[&](int u,int f,ll dep,vector<ll>& dis) {
      |     ^~~~~~~~
      |     union
answer.code:11:41: error: expression list treated as compound expression in functional cast [-fpermissive]
   11 |     function<void(int,int,ll,vector<ll>&)> dfs=[&](int u,int f,ll dep,vector<ll>& dis) {
      |                                         ^
answer.code:11:14: error: expected primary-expression before ‘void’
   11 |     function<void(int,int,ll,vector<ll>&)> dfs=[&](int u,int f,ll dep,vector<ll>& dis) {
      |              ^~~~
answer.code:18:5: error: ‘dfs’ was not declared in this scope
   18 |     dfs(X,0,0ll,dis1);
      |     ^~~
answer.code:20:5: error: ‘map’ was not declared in this scope
   20 |     map<ll,vector<ll>> grp;
      |     ^~~
answer.code:20:24: error: ‘grp’ was not declared in this scope
   20 |     map<ll,vector<ll>> grp;
      |                        ^~~
answer.code:21:16: error: ‘w’ was not declared in this scope
   21 |     vector<ll> w;
      |                ^
answer.code:23:14: error: ‘min’ was not declared in this scope
   23 |         w.pb(min(dis1[i],dis2[i]));
      |              ^~~
answer.code:27:10: error: ‘all’ was not declared in this scope
   27 |     sort(all(w));
      |          ^~~
answer.code:27:5: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   27 |     sort(all(w));
      |     ^~~~
      |     short
answer.code:29:7: error: expected ‘;’ before ‘s’
   29 |     ll s=0;
      |       ^~
      |       ;
answer.code:31:9: error: ‘s’ was not declared in this scope
   31 |         s+=x;
      |         ^
answer.code:35:12: error: ‘min’ was not declared in this scope
   35 |         K-=min(dis1[i],dis2[i]);
      |            ^~~
answer.code:36:13: error: ‘abs’ was not declared in this scope
   36 |         grp[abs(dis1[i]-dis2[i])].pb(0);
      |             ^~~
answer.code:38:13: error: ‘abs’ was not declared in this scope
   38 |         grp[abs(dis1[i]-dis2[i])].pb(min(dis1[i],dis2[i]));
      |             ^~~
answer.code:38:38: error: ‘min’ was not declared in this scope
   38 |         grp[abs(dis1[i]-dis2[i])].pb(min(dis1[i],dis2[i]));
      |                                      ^~~
answer.code:40:16: error: ‘ret’ was not declared in this scope
   40 |     vector<ll> ret{0ll};
      |                ^~~
answer.code:43:20: error: ‘q1’ was not declared in this scope
   43 |         vector<ll> q1,q2,dp;
      |                    ^~
answer.code:43:23: error: ‘q2’ was not declared in this scope
   43 |         vector<ll> q1,q2,dp;
      |                       ^~
answer.code:43:26: error: ‘dp’ was not declared in this scope
   43 |         vector<ll> q1,q2,dp;
      |                          ^~
answer.code:45:11: error: expected ‘;’ before ‘s’
   45 |         ll s=0; dp.pb(0);
      |           ^~
      |           ;
answer.code:46:27: error: ‘s’ was not declared in this scope
   46 |         for (auto x:q1) { s+=x; dp.pb(s); }
      |                           ^
answer.code:47:17: error: ‘SZ’ was not declared in this scope
   47 |         rep(i,0,SZ(q1)) { s+=d; dp.pb(s); }
      |                 ^~
answer.code:49:13: error: ‘s’ was not declared in this scope
   49 |             s+=x; dp.pb(s);
      |             ^
answer.code:54:20: error: ‘tmp’ was not declared in this scope
   54 |         vector<ll> tmp(SZ(ret)+SZ(dp)-1,1ll<<60);
      |                    ^~~
answer.code:5...