Submission #1209316

#TimeUsernameProblemLanguageResultExecution timeMemory
1209316user736482Closing Time (IOI23_closing)C++20
Compilation error
0 ms0 KiB
int max_score(int n,int x,int y,ll k,vector<int>u,vector<int>v,vector<int>w){
    for(ll i=0;i<n+7;i++){
        g[i].clear();
    }
    for(ll i=0;i<n-1;i++){
        g[u[i]].pb({v[i],w[i]});
        g[v[i]].pb({u[i],w[i]});
    }
    dfs1(x,-1,0);
    dfs2(y,-1,0);
    vector<ll>v1,v3;
    vector<pair<ll,ll>>v2;
    ll K=k;
    ll dod=0;
    for(ll i=0;i<n;i++){
        v3.pb(min(dst1[i],dst2[i]));
        if(dst1[i]+dst2[i]==dst2[x]){
            //cout<<i<<" ";
            v1.pb(max(dst1[i],dst2[i])-min(dst1[i],dst2[i]));
            dod++;
            K-=min(dst1[i],dst2[i]);
        }
        else{
            if(min(dst1[i],dst2[i])*2<=max(dst1[i],dst2[i])){
                v1.pb(min(dst1[i],dst2[i]));
                v1.pb(max(dst1[i],dst2[i])-min(dst1[i],dst2[i]));
            }
            else{
                v2.pb({max(dst1[i],dst2[i]),min(dst1[i],dst2[i])});
            }
        }
    }
    ll wyn1=0;
    ll pom=k;
    //cout<<k<<" ";
    sort(v3.begin(),v3.end());
    for(ll i=0;i<n;i++){
        if(pom-v3[i]<0)break;
        pom-=v3[i];
        //cout<<"xd";
        wyn1++;
    }
    if(K<0)return wyn1;
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    multiset<ll>s1,s2;
    ll ak=v2.size();//pierwszy niewiziety
    ll akwyn=2*v2.size()+dod-1;
    for(pair<ll,ll> i : v2){
        K-=i.ff;
        s1.insert(i.ff-i.ss);
    }
    for(ll i=0;i<=v1.size();i++){
        if(i){
            K-=v1[i-1];
        }
        akwyn++;
        while(K<0){
            if(ak==0)return wyn1;
            akwyn-=2;
            K+=v2[--ak].ff;
            s1.erase(s1.lower_bound(v2[ak].ff-v2[ak].ss));
            s2.insert(v2[ak].ss);
        }
        ll czy=0;
        if(s2.size() && *s2.begin()<=K)czy=1;
        if(s1.size() && ak<v2.size() && (*--s1.end())+K>=v2[ak].ff)czy=1;
        wyn1=max(wyn1,akwyn+czy);
    }
    return wyn1;
}

Compilation message (stderr)

closing.cpp:1:33: error: 'll' has not been declared
    1 | int max_score(int n,int x,int y,ll k,vector<int>u,vector<int>v,vector<int>w){
      |                                 ^~
closing.cpp:1:38: error: 'vector' has not been declared
    1 | int max_score(int n,int x,int y,ll k,vector<int>u,vector<int>v,vector<int>w){
      |                                      ^~~~~~
closing.cpp:1:44: error: expected ',' or '...' before '<' token
    1 | int max_score(int n,int x,int y,ll k,vector<int>u,vector<int>v,vector<int>w){
      |                                            ^
closing.cpp: In function 'int max_score(int, int, int, int, int)':
closing.cpp:2:9: error: 'll' was not declared in this scope
    2 |     for(ll i=0;i<n+7;i++){
      |         ^~
closing.cpp:2:16: error: 'i' was not declared in this scope
    2 |     for(ll i=0;i<n+7;i++){
      |                ^
closing.cpp:3:9: error: 'g' was not declared in this scope
    3 |         g[i].clear();
      |         ^
closing.cpp:5:9: error: 'll' was not declared in this scope
    5 |     for(ll i=0;i<n-1;i++){
      |         ^~
closing.cpp:5:16: error: 'i' was not declared in this scope
    5 |     for(ll i=0;i<n-1;i++){
      |                ^
closing.cpp:6:9: error: 'g' was not declared in this scope
    6 |         g[u[i]].pb({v[i],w[i]});
      |         ^
closing.cpp:6:11: error: 'u' was not declared in this scope
    6 |         g[u[i]].pb({v[i],w[i]});
      |           ^
closing.cpp:6:21: error: 'v' was not declared in this scope
    6 |         g[u[i]].pb({v[i],w[i]});
      |                     ^
closing.cpp:6:26: error: 'w' was not declared in this scope
    6 |         g[u[i]].pb({v[i],w[i]});
      |                          ^
closing.cpp:9:5: error: 'dfs1' was not declared in this scope
    9 |     dfs1(x,-1,0);
      |     ^~~~
closing.cpp:10:5: error: 'dfs2' was not declared in this scope
   10 |     dfs2(y,-1,0);
      |     ^~~~
closing.cpp:11:12: error: 'll' was not declared in this scope
   11 |     vector<ll>v1,v3;
      |            ^~
closing.cpp:11:5: error: 'vector' was not declared in this scope
   11 |     vector<ll>v1,v3;
      |     ^~~~~~
closing.cpp:11:15: error: 'v1' was not declared in this scope
   11 |     vector<ll>v1,v3;
      |               ^~
closing.cpp:11:18: error: 'v3' was not declared in this scope
   11 |     vector<ll>v1,v3;
      |                  ^~
closing.cpp:12:12: error: 'pair' was not declared in this scope
   12 |     vector<pair<ll,ll>>v2;
      |            ^~~~
closing.cpp:12:24: error: 'v2' was not declared in this scope
   12 |     vector<pair<ll,ll>>v2;
      |                        ^~
closing.cpp:13:7: error: expected ';' before 'K'
   13 |     ll K=k;
      |       ^~
      |       ;
closing.cpp:14:7: error: expected ';' before 'dod'
   14 |     ll dod=0;
      |       ^~~~
      |       ;
closing.cpp:15:11: error: expected ';' before 'i'
   15 |     for(ll i=0;i<n;i++){
      |           ^~
      |           ;
closing.cpp:15:16: error: 'i' was not declared in this scope
   15 |     for(ll i=0;i<n;i++){
      |                ^
closing.cpp:16:19: error: 'dst1' was not declared in this scope
   16 |         v3.pb(min(dst1[i],dst2[i]));
      |                   ^~~~
closing.cpp:16:27: error: 'dst2' was not declared in this scope
   16 |         v3.pb(min(dst1[i],dst2[i]));
      |                           ^~~~
closing.cpp:16:15: error: 'min' was not declared in this scope
   16 |         v3.pb(min(dst1[i],dst2[i]));
      |               ^~~
closing.cpp:19:19: error: 'max' was not declared in this scope
   19 |             v1.pb(max(dst1[i],dst2[i])-min(dst1[i],dst2[i]));
      |                   ^~~
closing.cpp:20:13: error: 'dod' was not declared in this scope
   20 |             dod++;
      |             ^~~
closing.cpp:21:13: error: 'K' was not declared in this scope
   21 |             K-=min(dst1[i],dst2[i]);
      |             ^
closing.cpp:24:40: error: 'max' was not declared in this scope
   24 |             if(min(dst1[i],dst2[i])*2<=max(dst1[i],dst2[i])){
      |                                        ^~~
closing.cpp:33:7: error: expected ';' before 'wyn1'
   33 |     ll wyn1=0;
      |       ^~~~~
      |       ;
closing.cpp:34:7: error: expected ';' before 'pom'
   34 |     ll pom=k;
      |       ^~~~
      |       ;
closing.cpp:36:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   36 |     sort(v3.begin(),v3.end());
      |     ^~~~
      |     short
closing.cpp:37:11: error: expected ';' before 'i'
   37 |     for(ll i=0;i<n;i++){
      |           ^~
      |           ;
closing.cpp:37:16: error: 'i' was not declared in this scope
   37 |     for(ll i=0;i<n;i++){
      |                ^
closing.cpp:38:12: error: 'pom' was not declared in this scope
   38 |         if(pom-v3[i]<0)break;
      |            ^~~
closing.cpp:39:9: error: 'pom' was not declared in this scope
   39 |         pom-=v3[i];
      |         ^~~
closing.cpp:41:9: error: 'wyn1' was not declared in this scope
   41 |         wyn1++;
      |         ^~~~
closing.cpp:43:8: error: 'K' was not declared in this scope
   43 |     if(K<0)return wyn1;
      |        ^
closing.cpp:43:19: error: 'wyn1' was not declared in this scope
   43 |     if(K<0)return wyn1;
      |                   ^~~~
closing.cpp:46:5: error: 'multiset' was not declared in this scope
   46 |     multiset<ll>s1,s2;
      |     ^~~~~~~~
closing.cpp:46:17: error: 's1' was not declared in this scope
   46 |     multiset<ll>s1,s2;
      |                 ^~
closing.cpp:46:20: error: 's2' was not declared in this scope
   46 |     multiset<ll>s1,s2;
      |                    ^~
closing.cpp:47:7: error: expected ';' before 'ak'
   47 |     ll ak=v2.size();//pierwszy niewiziety
      |       ^~~
      |       ;
closing.cpp:48:7: error: expected ';' before 'akwyn'
   48 |     ll akwyn=2*v2.size()+dod-1;
      |       ^~~~~~
      |       ;
closing.cpp:49:23: error: found ':' in nested-name-specifier, expected '::'
   49 |     for(pair<ll,ll> i : v2){
      |                       ^
      |                       ::
closing.cpp:49:21: error: 'i' has not been declared
   49 |     for(pair<ll,ll> i : v2){
      |                     ^
closing.cpp:53:5: error: expected primary-expression before 'for'
   53 |     for(ll i=0;i<=v1.size();i++){
      |     ^~~
closing.cpp:52:6: error: expected ';' before 'for'
   52 |     }
      |      ^
      |      ;
   53 |     for(ll i=0;i<=v1.size();i++){
      |     ~~~
closing.cpp:53:5: error: expected primary-expression before 'for'
   53 |     for(ll i=0;i<=v1.size();i++){
      |     ^~~
closing.cpp:52:6: error: expected ')' before 'for'
   52 |     }
      |      ^
      |      )
   53 |     for(ll i=0;i<=v1.size();i++){
      |     ~~~
closing.cpp:49:8: note: to match this '('
   49 |     for(pair<ll,ll> i : v2){
      |        ^
closing.cpp:53:11: error: expected ';' before 'i'
   53 |     for(ll i=0;i<=v1.size();i++){
      |           ^~
      |           ;
closing.cpp:53:16: error: 'i' was not declared in this scope
   53 |     for(ll i=0;i<=v1.size();i++){
      |                ^
closing.cpp:55:13: error: 'K' was not declared in this scope
   55 |             K-=v1[i-1];
      |             ^
closing.cpp:57:9: error: 'akwyn' was not declared in this scope
   57 |         akwyn++;
      |         ^~~~~
closing.cpp:58:15: error: 'K' was not declared in this scope
   58 |         while(K<0){
      |               ^
closing.cpp:59:16: error: 'ak' was not declared in this scope; did you mean 'k'?
   59 |             if(ak==0)return wyn1;
      |                ^~
      |                k
closing.cpp:59:29: error: 'wyn1' was not declared in this scope
   59 |             if(ak==0)return wyn1;
      |                             ^~~~
closing.cpp:61:21: error: 'ak' was not declared in this scope; did you mean 'k'?
   61 |             K+=v2[--ak].ff;
      |                     ^~
      |                     k
closing.cpp:65:11: error: expected ';' before 'czy'
   65 |         ll czy=0;
      |           ^~~~
      |           ;
closing.cpp:66:38: error: 'K' was not declared in this scope
   66 |         if(s2.size() && *s2.begin()<=K)czy=1;
      |                                      ^
closing.cpp:66:40: error: 'czy' was not declared in this scope
   66 |         if(s2.size() && *s2.begin()<=K)czy=1;
      |                                        ^~~
closing.cpp:67:55: error: 'K' was not declared in this scope
   67 |         if(s1.size() && ak<v2.size() && (*--s1.end())+K>=v2[ak].ff)czy=1;
      |                                                       ^
closing.cpp:67:61: error: 'ak' was not declared in this scope; did you mean 'k'?
   67 |         if(s1.size() && ak<v2.size() && (*--s1.end())+K>=v2[ak].ff)czy=1;
      |                                                             ^~
      |                                                             k
closing.cpp:67:68: error: 'czy' was not declared in this scope
   67 |         if(s1.size() && ak<v2.size() && (*--s1.end())+K>=v2[ak].ff)czy=1;
      |                                                                    ^~~
closing.cpp:68:9: error: 'wyn1' was not declared in this scope
   68 |         wyn1=max(wyn1,akwyn+czy);
      |         ^~~~
closing.cpp:68:29: error: 'czy' was not declared in this scope
   68 |         wyn1=max(wyn1,akwyn+czy);
      |                             ^~~
closing.cpp:68:14: error: 'max' was not declared in this scope
   68 |         wyn1=max(wyn1,akwyn+czy);
      |              ^~~
closing.cpp:70:12: error: 'wyn1' was not declared in this scope
   70 |     return wyn1;
      |            ^~~~