Submission #282333

# Submission time Handle Problem Language Result Execution time Memory
282333 2020-08-24T10:16:13 Z iliccmarko Traffic (IOI10_traffic) C++14
Compilation error
0 ms 0 KB
int dfs(int u, int pret, vector<vector<int> > g, long long &ans, int &ind, long long svi)
{
    long long br = 0;
    for(int i = 0;i<(int)g[u].size();i++)
    {
        int s = g[u][i];
        if(s==pret) continue;
        br+=dfs(s, u);
    }
    
    if(br<ans)
    {
        ans = br;
        ind = u;
    }
    if(svi - br - p[u]<ans)
    {
        ans = svi - br - p[u];
        ind = u;
    }
        
    return br + p[u];
}

int LocateCenter(int n, int p[], int s[], int d[])
{
    vector<vector<int> > g(1000);
    for(int i = 1;i<=n-1;i++)
    {
        int a = s[i];
        int b = d[i];
        g[a].push_back(b);
        g[b].push_back(a);
    }
    long long svi = 0;
    for(int i = 1;i<=n;i++)
    {
        svi+=p[i];
    }
    long long ans = LLONG_MAX;
    int ind;
    dfs(1, -1, g, ans, ind, svi);
    return ind;
}

Compilation message

traffic.cpp:1:26: error: 'vector' has not been declared
    1 | int dfs(int u, int pret, vector<vector<int> > g, long long &ans, int &ind, long long svi)
      |                          ^~~~~~
traffic.cpp:1:32: error: expected ',' or '...' before '<' token
    1 | int dfs(int u, int pret, vector<vector<int> > g, long long &ans, int &ind, long long svi)
      |                                ^
traffic.cpp: In function 'int dfs(int, int, int)':
traffic.cpp:4:26: error: 'g' was not declared in this scope
    4 |     for(int i = 0;i<(int)g[u].size();i++)
      |                          ^
traffic.cpp:8:21: error: too few arguments to function 'int dfs(int, int, int)'
    8 |         br+=dfs(s, u);
      |                     ^
traffic.cpp:1:5: note: declared here
    1 | int dfs(int u, int pret, vector<vector<int> > g, long long &ans, int &ind, long long svi)
      |     ^~~
traffic.cpp:11:11: error: 'ans' was not declared in this scope
   11 |     if(br<ans)
      |           ^~~
traffic.cpp:14:9: error: 'ind' was not declared in this scope; did you mean 'int'?
   14 |         ind = u;
      |         ^~~
      |         int
traffic.cpp:16:8: error: 'svi' was not declared in this scope
   16 |     if(svi - br - p[u]<ans)
      |        ^~~
traffic.cpp:16:19: error: 'p' was not declared in this scope
   16 |     if(svi - br - p[u]<ans)
      |                   ^
traffic.cpp:16:24: error: 'ans' was not declared in this scope
   16 |     if(svi - br - p[u]<ans)
      |                        ^~~
traffic.cpp:19:9: error: 'ind' was not declared in this scope; did you mean 'int'?
   19 |         ind = u;
      |         ^~~
      |         int
traffic.cpp:22:17: error: 'p' was not declared in this scope
   22 |     return br + p[u];
      |                 ^
traffic.cpp: In function 'int LocateCenter(int, int*, int*, int*)':
traffic.cpp:27:5: error: 'vector' was not declared in this scope
   27 |     vector<vector<int> > g(1000);
      |     ^~~~~~
traffic.cpp:27:19: error: expected primary-expression before 'int'
   27 |     vector<vector<int> > g(1000);
      |                   ^~~
traffic.cpp:32:9: error: 'g' was not declared in this scope
   32 |         g[a].push_back(b);
      |         ^
traffic.cpp:40:21: error: 'LLONG_MAX' was not declared in this scope
   40 |     long long ans = LLONG_MAX;
      |                     ^~~~~~~~~
traffic.cpp:1:1: note: 'LLONG_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
  +++ |+#include <climits>
    1 | int dfs(int u, int pret, vector<vector<int> > g, long long &ans, int &ind, long long svi)
traffic.cpp:42:16: error: 'g' was not declared in this scope
   42 |     dfs(1, -1, g, ans, ind, svi);
      |                ^