Submission #465269

# Submission time Handle Problem Language Result Execution time Memory
465269 2021-08-15T12:52:42 Z MohamedFaresNebili Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
int n, m, k; vector<pair<int, long long>>adj[100000];
vector<int>ex; vector<bool>e; long long d[1024][1024];
long long dfs(int v, int p)
{
    if(e[v]) return 0;
    long long best=1e9, ans=1e9; int node=-1;
    for(auto u:adj[v]) {
        int to=u.first; long long w=u.second;
        if(to==p) continue;
		long long cnt=1e9;
		for(int l=0;l<k;l++) cnt=min(cnt, d[l][to]);
        if(cnt+w<best) node=to, best=cnt+w;
    }
    for(auto u:adj[v]) {
        int to=u.first; long long w=u.second;
        if(to==p||to==node) continue;
        ans=min(ans, w+dfs(to, v));
    }
    return ans;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n=N, m=M, k=K; e.assign(n, false);
    for(int l=0;l<m;l++) {
        int a=R[l][0], b=R[l][1]; long long w=L[l];
        adj[a].push_back({b, w}); adj[b].push_back({a, w});
    }
    for(int l=0;l<k;l++) {
        int i=P[l]; e[i]=true; ex.push_back(i);
    }
	int cnt=0;
	for(auto u:ex) {
		for(int i=0;i<n;i++) d[cnt][i]=1e9; d[cnt][u]=0;
		priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>pq;
        pq.push({0, u}); vector<bool>vis(n);
        while(!pq.empty()) {
            int a=pq.top().second; pq.pop();
            for(auto u:adj[a]) {
                if(d[cnt][u.first]>d[cnt][a]+u.second) {
                    d[cnt][u.first]=d[cnt][a]+u.second;
                    pq.push({d[cnt][u.first], u.first});
                }
            }
        }
        cnt++;
	}
    N=dfs(0, -1);
    return N;
}

Compilation message

crocodile.cpp:1:14: error: 'vector' does not name a type
    1 | int n, m, k; vector<pair<int, long long>>adj[100000];
      |              ^~~~~~
crocodile.cpp:2:1: error: 'vector' does not name a type
    2 | vector<int>ex; vector<bool>e; long long d[1024][1024];
      | ^~~~~~
crocodile.cpp:2:16: error: 'vector' does not name a type
    2 | vector<int>ex; vector<bool>e; long long d[1024][1024];
      |                ^~~~~~
crocodile.cpp: In function 'long long int dfs(int, int)':
crocodile.cpp:5:8: error: 'e' was not declared in this scope
    5 |     if(e[v]) return 0;
      |        ^
crocodile.cpp:7:16: error: 'adj' was not declared in this scope
    7 |     for(auto u:adj[v]) {
      |                ^~~
crocodile.cpp:11:28: error: 'min' was not declared in this scope
   11 |   for(int l=0;l<k;l++) cnt=min(cnt, d[l][to]);
      |                            ^~~
crocodile.cpp:14:16: error: 'adj' was not declared in this scope
   14 |     for(auto u:adj[v]) {
      |                ^~~
crocodile.cpp:17:13: error: 'min' was not declared in this scope
   17 |         ans=min(ans, w+dfs(to, v));
      |             ^~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:24:20: error: 'e' was not declared in this scope
   24 |     n=N, m=M, k=K; e.assign(n, false);
      |                    ^
crocodile.cpp:27:9: error: 'adj' was not declared in this scope
   27 |         adj[a].push_back({b, w}); adj[b].push_back({a, w});
      |         ^~~
crocodile.cpp:30:32: error: 'ex' was not declared in this scope
   30 |         int i=P[l]; e[i]=true; ex.push_back(i);
      |                                ^~
crocodile.cpp:33:13: error: 'ex' was not declared in this scope
   33 |  for(auto u:ex) {
      |             ^~
crocodile.cpp:34:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   34 |   for(int i=0;i<n;i++) d[cnt][i]=1e9; d[cnt][u]=0;
      |   ^~~
crocodile.cpp:34:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   34 |   for(int i=0;i<n;i++) d[cnt][i]=1e9; d[cnt][u]=0;
      |                                       ^
crocodile.cpp:35:3: error: 'priority_queue' was not declared in this scope
   35 |   priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>pq;
      |   ^~~~~~~~~~~~~~
crocodile.cpp:35:18: error: 'pair' was not declared in this scope
   35 |   priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>pq;
      |                  ^~~~
crocodile.cpp:35:23: error: expected primary-expression before 'long'
   35 |   priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>pq;
      |                       ^~~~
crocodile.cpp:36:9: error: 'pq' was not declared in this scope
   36 |         pq.push({0, u}); vector<bool>vis(n);
      |         ^~
crocodile.cpp:36:26: error: 'vector' was not declared in this scope
   36 |         pq.push({0, u}); vector<bool>vis(n);
      |                          ^~~~~~
crocodile.cpp:36:33: error: expected primary-expression before 'bool'
   36 |         pq.push({0, u}); vector<bool>vis(n);
      |                                 ^~~~
crocodile.cpp:39:24: error: 'adj' was not declared in this scope
   39 |             for(auto u:adj[a]) {
      |                        ^~~