Submission #460815

# Submission time Handle Problem Language Result Execution time Memory
460815 2021-08-09T09:59:34 Z BT21tata Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "crocodile.h"
typedef long long ll;

using namespace std;

vector<pair<ll,ll> >g[100005];
priority_queue<pair<ll,ll> >q;
ll dis[100005], ans;
bool used[100005], ext[100005];

void dfs(int v, int p)
{
    for(pair<ll, ll> u : g[v])
    {
        if(u.first!=p)
        {
            dis[u.first]=dis[v]+u.second;
            dfs(u.first, v);
        }
    }
}

ll ans(int v, int p)
{
    vector<int>w;
    for(pair<ll, ll> u : g[v])
    {
        if(u.first==p) continue;
        if(ext[u.first]) w.push_back(dis[u.first]);
        else w.push_back(ans(u.first, v));
    }
    sort(w.begin(), w.end());
    return w[1];
}

int travel_plan(int n, int m, int R[][2], int L[], int k, int p[])
{
    for(int i=0; i<m; i++)
    {
        g[R[i][0]].push_back({R[i][1], L[i]});
        g[R[i][1]].push_back({R[i][0], L[i]});
    }

    for(int i=0; i<k; i++)
        ext[P[i]]=1;
    dis[0]=0;
    dfs(0, 0);
    
    return ans(0, 0);
}


/*
5 4 3
0 1 2
0 2 3
3 2 1
2 4 4
1 3 4
7

*/

Compilation message

crocodile.cpp:24:20: error: 'll ans(int, int)' redeclared as different kind of entity
   24 | ll ans(int v, int p)
      |                    ^
crocodile.cpp:9:17: note: previous declaration 'll ans'
    9 | ll dis[100005], ans;
      |                 ^~~
crocodile.cpp: In function 'll ans(int, int)':
crocodile.cpp:31:40: error: 'ans' cannot be used as a function
   31 |         else w.push_back(ans(u.first, v));
      |                                        ^
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:46:13: error: 'P' was not declared in this scope
   46 |         ext[P[i]]=1;
      |             ^
crocodile.cpp:50:20: error: 'ans' cannot be used as a function
   50 |     return ans(0, 0);
      |                    ^