Submission #844694

# Submission time Handle Problem Language Result Execution time Memory
844694 2023-09-05T17:11:37 Z oneloveforever Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ii pair<int,int>
int n,a,b,k;
vector<vector<ii> >edge;
int Sub1()
{
    queue<int>q;
    vector<vector<ll> >dist(2,vector<ll>(n+1,-1));
    vector<int>source(2);
    source[0]=a;
    source[1]=b;
    for(int i=0;i<=1;i++)
    {
        queue<int>q;
        q.push(source[i]);
        dist[i][source[i]]=0;
        while(!q.empty())
        {
            int x=q.front();
            q.pop();
            for(ii need:edge[x])
            {
                int node=need.x;
                int value=need.y;
                if(dist[i][node]==-1)
                {
                    dist[i][node]=dist[i][x]+value;
                    q.push(node);
                }
            }
        }
    }
    vector<ll>que;
    for(int i=0;i<=n-1;i++)
    {
        que.push_back(dist[0][i]);
        que.push_back(dist[1][i]);
    }
    sort(que.begin(),que.end());
    ll res=k;
    int ans=0;
    for(int value:que)
    {
        if(res<value)break;
        res-=value;
        ans++;
    }
    return ans;
}
int max_score(int N,int X,int Y,long long K,vector<int>U,vector<int>V,vector<int>W)
{
    n=N;
    a=X;
    b=Y;
    k=K;
    edge.resize(n);
    for(int i=0;i<N-1;i++)
    {
        int x=U[i];
        int y=V[i];
        int value=W[i];
        edge[x].push_back({y,value});
        edge[y].push_back({x,value});
    }
    return Sub1();


}

/*int main()
{
    int n,x,y,k;
    vector<int>U;
    vector<int>V;
    vector<int>W;
    cin>>n>>x>>y>>k;
    for(int i=1;i<=n-1;i++)
    {
        int x;
        cin>>x;
        U.push_back(x);
    }
    for(int i=1;i<=n-1;i++)
    {
        int y;
        cin>>y;
        V.push_back(y);
    }
    for(int i=1;i<=n-1;i++)
    {
        int value;
        cin>>value;
        W.push_back(value);
    }
    cout<<max_score(n,x,y,k,U,V,W);
}*/

Compilation message

closing.cpp: In function 'int Sub1()':
closing.cpp:12:19: error: 'll' was not declared in this scope
   12 |     vector<vector<ll> >dist(2,vector<ll>(n+1,-1));
      |                   ^~
closing.cpp:12:21: error: template argument 1 is invalid
   12 |     vector<vector<ll> >dist(2,vector<ll>(n+1,-1));
      |                     ^
closing.cpp:12:21: error: template argument 2 is invalid
closing.cpp:12:23: error: template argument 1 is invalid
   12 |     vector<vector<ll> >dist(2,vector<ll>(n+1,-1));
      |                       ^
closing.cpp:12:23: error: template argument 2 is invalid
closing.cpp:12:40: error: template argument 2 is invalid
   12 |     vector<vector<ll> >dist(2,vector<ll>(n+1,-1));
      |                                        ^
closing.cpp:12:49: error: expression list treated as compound expression in initializer [-fpermissive]
   12 |     vector<vector<ll> >dist(2,vector<ll>(n+1,-1));
      |                                                 ^
closing.cpp:20:13: error: invalid types 'int[int]' for array subscript
   20 |         dist[i][source[i]]=0;
      |             ^
closing.cpp:29:24: error: invalid types 'int[int]' for array subscript
   29 |                 if(dist[i][node]==-1)
      |                        ^
closing.cpp:31:25: error: invalid types 'int[int]' for array subscript
   31 |                     dist[i][node]=dist[i][x]+value;
      |                         ^
closing.cpp:31:39: error: invalid types 'int[int]' for array subscript
   31 |                     dist[i][node]=dist[i][x]+value;
      |                                       ^
closing.cpp:37:14: error: template argument 2 is invalid
   37 |     vector<ll>que;
      |              ^
closing.cpp:40:13: error: request for member 'push_back' in 'que', which is of non-class type 'int'
   40 |         que.push_back(dist[0][i]);
      |             ^~~~~~~~~
closing.cpp:40:27: error: invalid types 'int[int]' for array subscript
   40 |         que.push_back(dist[0][i]);
      |                           ^
closing.cpp:41:13: error: request for member 'push_back' in 'que', which is of non-class type 'int'
   41 |         que.push_back(dist[1][i]);
      |             ^~~~~~~~~
closing.cpp:41:27: error: invalid types 'int[int]' for array subscript
   41 |         que.push_back(dist[1][i]);
      |                           ^
closing.cpp:43:14: error: request for member 'begin' in 'que', which is of non-class type 'int'
   43 |     sort(que.begin(),que.end());
      |              ^~~~~
closing.cpp:43:26: error: request for member 'end' in 'que', which is of non-class type 'int'
   43 |     sort(que.begin(),que.end());
      |                          ^~~
closing.cpp:44:7: error: expected ';' before 'res'
   44 |     ll res=k;
      |       ^~~~
      |       ;
closing.cpp:46:19: error: 'begin' was not declared in this scope
   46 |     for(int value:que)
      |                   ^~~
closing.cpp:46:19: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from closing.cpp:2:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from closing.cpp:2:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
closing.cpp:46:19: error: 'end' was not declared in this scope
   46 |     for(int value:que)
      |                   ^~~
closing.cpp:46:19: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from closing.cpp:2:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from closing.cpp:2:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
closing.cpp:48:12: error: 'res' was not declared in this scope
   48 |         if(res<value)break;
      |            ^~~
closing.cpp:49:9: error: 'res' was not declared in this scope
   49 |         res-=value;
      |         ^~~