Submission #465474

# Submission time Handle Problem Language Result Execution time Memory
465474 2021-08-16T08:04:21 Z MohamedFaresNebili Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    int n=N, m=M, k=K; vector<pair<long long, int>>adj[n]; vector<int> dis(n, -1);
    vector<bool>exit(n, false); vector<long long>d(n, 1e10); vector<bool>queued(n, false);
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>pq;
    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 a=P[l]; dis[a]=0;
        pq.push({0, a}); d[a]=0;
    }
    vector<long long>len[n]; vector<int>income(n, 0); queue<int>q;
    while(!pq.empty()) {
        int a=pq.top().second; long long w=pq.top().second;
      	queued[a]=true; pq.pop();
        for(auto u:adj[a]) {
            int to=u.first; long long s=u.second;
            if(queued[to]) continue; q.push(to);
            len[to].push_back(d[a]+s); income[to]++;
        }
      	if(pq.empty()) {
          while(!q.empty()) {
            	int to=q.front(); q.pop();
                if(income[to]>1) {
                  sort(len[to].begin(), len[to].end());
                  pq.push({len[to][1], to});
                  d[to]=len[to][1];
            	}
          }
        }
    }
    return (d[0]!=1e10?d[0]:-1);
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:3:24: error: 'vector' was not declared in this scope
    3 |     int n=N, m=M, k=K; vector<pair<long long, int>>adj[n]; vector<int> dis(n, -1);
      |                        ^~~~~~
crocodile.cpp:3:31: error: 'pair' was not declared in this scope
    3 |     int n=N, m=M, k=K; vector<pair<long long, int>>adj[n]; vector<int> dis(n, -1);
      |                               ^~~~
crocodile.cpp:3:36: error: expected primary-expression before 'long'
    3 |     int n=N, m=M, k=K; vector<pair<long long, int>>adj[n]; vector<int> dis(n, -1);
      |                                    ^~~~
crocodile.cpp:3:67: error: expected primary-expression before 'int'
    3 |     int n=N, m=M, k=K; vector<pair<long long, int>>adj[n]; vector<int> dis(n, -1);
      |                                                                   ^~~
crocodile.cpp:4:12: error: expected primary-expression before 'bool'
    4 |     vector<bool>exit(n, false); vector<long long>d(n, 1e10); vector<bool>queued(n, false);
      |            ^~~~
crocodile.cpp:4:40: error: expected primary-expression before 'long'
    4 |     vector<bool>exit(n, false); vector<long long>d(n, 1e10); vector<bool>queued(n, false);
      |                                        ^~~~
crocodile.cpp:4:69: error: expected primary-expression before 'bool'
    4 |     vector<bool>exit(n, false); vector<long long>d(n, 1e10); vector<bool>queued(n, false);
      |                                                                     ^~~~
crocodile.cpp:5:5: error: 'priority_queue' was not declared in this scope
    5 |     priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>pq;
      |     ^~~~~~~~~~~~~~
crocodile.cpp:5:25: error: expected primary-expression before 'long'
    5 |     priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>pq;
      |                         ^~~~
crocodile.cpp:8:9: error: 'adj' was not declared in this scope
    8 |         adj[a].push_back({b, w});
      |         ^~~
crocodile.cpp:12:21: error: 'dis' was not declared in this scope
   12 |         int a=P[l]; dis[a]=0;
      |                     ^~~
crocodile.cpp:13:9: error: 'pq' was not declared in this scope
   13 |         pq.push({0, a}); d[a]=0;
      |         ^~
crocodile.cpp:13:26: error: 'd' was not declared in this scope
   13 |         pq.push({0, a}); d[a]=0;
      |                          ^
crocodile.cpp:15:12: error: expected primary-expression before 'long'
   15 |     vector<long long>len[n]; vector<int>income(n, 0); queue<int>q;
      |            ^~~~
crocodile.cpp:15:37: error: expected primary-expression before 'int'
   15 |     vector<long long>len[n]; vector<int>income(n, 0); queue<int>q;
      |                                     ^~~
crocodile.cpp:15:55: error: 'queue' was not declared in this scope
   15 |     vector<long long>len[n]; vector<int>income(n, 0); queue<int>q;
      |                                                       ^~~~~
crocodile.cpp:15:61: error: expected primary-expression before 'int'
   15 |     vector<long long>len[n]; vector<int>income(n, 0); queue<int>q;
      |                                                             ^~~
crocodile.cpp:16:12: error: 'pq' was not declared in this scope
   16 |     while(!pq.empty()) {
      |            ^~
crocodile.cpp:18:8: error: 'queued' was not declared in this scope
   18 |        queued[a]=true; pq.pop();
      |        ^~~~~~
crocodile.cpp:19:20: error: 'adj' was not declared in this scope
   19 |         for(auto u:adj[a]) {
      |                    ^~~
crocodile.cpp:21:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   21 |             if(queued[to]) continue; q.push(to);
      |             ^~
crocodile.cpp:21:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   21 |             if(queued[to]) continue; q.push(to);
      |                                      ^
crocodile.cpp:21:38: error: 'q' was not declared in this scope
crocodile.cpp:22:13: error: 'len' was not declared in this scope
   22 |             len[to].push_back(d[a]+s); income[to]++;
      |             ^~~
crocodile.cpp:22:31: error: 'd' was not declared in this scope
   22 |             len[to].push_back(d[a]+s); income[to]++;
      |                               ^
crocodile.cpp:22:40: error: 'income' was not declared in this scope
   22 |             len[to].push_back(d[a]+s); income[to]++;
      |                                        ^~~~~~
crocodile.cpp:25:18: error: 'q' was not declared in this scope
   25 |           while(!q.empty()) {
      |                  ^
crocodile.cpp:27:20: error: 'income' was not declared in this scope
   27 |                 if(income[to]>1) {
      |                    ^~~~~~
crocodile.cpp:28:24: error: 'len' was not declared in this scope
   28 |                   sort(len[to].begin(), len[to].end());
      |                        ^~~
crocodile.cpp:28:19: error: 'sort' was not declared in this scope; did you mean 'short'?
   28 |                   sort(len[to].begin(), len[to].end());
      |                   ^~~~
      |                   short
crocodile.cpp:30:19: error: 'd' was not declared in this scope
   30 |                   d[to]=len[to][1];
      |                   ^
crocodile.cpp:17:42: warning: unused variable 'w' [-Wunused-variable]
   17 |         int a=pq.top().second; long long w=pq.top().second;
      |                                          ^
crocodile.cpp:35:13: error: 'd' was not declared in this scope
   35 |     return (d[0]!=1e10?d[0]:-1);
      |             ^
crocodile.cpp:3:9: warning: unused variable 'n' [-Wunused-variable]
    3 |     int n=N, m=M, k=K; vector<pair<long long, int>>adj[n]; vector<int> dis(n, -1);
      |         ^