Submission #465469

#TimeUsernameProblemLanguageResultExecution timeMemory
465469MohamedFaresNebiliCrocodile's Underground City (IOI11_crocodile)C++14
Compilation error
0 ms0 KiB
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, 1e9); queue<int>q; 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; q.push(a); } vector<bool>queued(n, false); vector<long long>len[n]; vector<int>income(n, 0); while(!pq.empty()) { int a=pq.top().second; long long w=pq.top().second; pq.pop(); queued[a]=true; for(auto u:adj[a]) { int to=u.first; long long s=u.second; if(d[a]+s>=d[to]) continue; len[to].push_back(d[a]+s); income[to]++; 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]!=1e9?d[0]:-1); }

Compilation message (stderr)

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, 1e9); queue<int>q;
      |            ^~~~
crocodile.cpp:4:40: error: expected primary-expression before 'long'
    4 |     vector<bool>exit(n, false); vector<long long>d(n, 1e9); queue<int>q;
      |                                        ^~~~
crocodile.cpp:4:61: error: 'queue' was not declared in this scope
    4 |     vector<bool>exit(n, false); vector<long long>d(n, 1e9); queue<int>q;
      |                                                             ^~~~~
crocodile.cpp:4:67: error: expected primary-expression before 'int'
    4 |     vector<bool>exit(n, false); vector<long long>d(n, 1e9); queue<int>q;
      |                                                                   ^~~
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; q.push(a);
      |         ^~
crocodile.cpp:13:26: error: 'd' was not declared in this scope
   13 |         pq.push({0, a}); d[a]=0; q.push(a);
      |                          ^
crocodile.cpp:13:34: error: 'q' was not declared in this scope
   13 |         pq.push({0, a}); d[a]=0; q.push(a);
      |                                  ^
crocodile.cpp:15:12: error: expected primary-expression before 'bool'
   15 |     vector<bool>queued(n, false);
      |            ^~~~
crocodile.cpp:16:12: error: expected primary-expression before 'long'
   16 |     vector<long long>len[n]; vector<int>income(n, 0);
      |            ^~~~
crocodile.cpp:16:37: error: expected primary-expression before 'int'
   16 |     vector<long long>len[n]; vector<int>income(n, 0);
      |                                     ^~~
crocodile.cpp:17:12: error: 'pq' was not declared in this scope
   17 |     while(!pq.empty()) {
      |            ^~
crocodile.cpp:19:19: error: 'queued' was not declared in this scope
   19 |         pq.pop(); queued[a]=true;
      |                   ^~~~~~
crocodile.cpp:20:20: error: 'adj' was not declared in this scope
   20 |         for(auto u:adj[a]) {
      |                    ^~~
crocodile.cpp:22:16: error: 'd' was not declared in this scope
   22 |             if(d[a]+s>=d[to]) continue;
      |                ^
crocodile.cpp:23:13: error: 'len' was not declared in this scope
   23 |             len[to].push_back(d[a]+s); income[to]++;
      |             ^~~
crocodile.cpp:23:31: error: 'd' was not declared in this scope
   23 |             len[to].push_back(d[a]+s); income[to]++;
      |                               ^
crocodile.cpp:23:40: error: 'income' was not declared in this scope
   23 |             len[to].push_back(d[a]+s); income[to]++;
      |                                        ^~~~~~
crocodile.cpp:25:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   25 |                 sort(len[to].begin(), len[to].end());
      |                 ^~~~
      |                 short
crocodile.cpp:18:42: warning: unused variable 'w' [-Wunused-variable]
   18 |         int a=pq.top().second; long long w=pq.top().second;
      |                                          ^
crocodile.cpp:31:13: error: 'd' was not declared in this scope
   31 |     return (d[0]!=1e9?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);
      |         ^