Submission #758257

#TimeUsernameProblemLanguageResultExecution timeMemory
758257ivazivaCrocodile's Underground City (IOI11_crocodile)C++14
Compilation error
0 ms0 KiB
#include "crocodile.h" #include <bits/stdc++.h> #define MAXN 1010 int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]) { long long n; long long m; long long k; vector<pair<long long long>> adj[MAXN]; long long niz[MAXN]; long long dist1[MAXN]; long long dist2[MAXN]; long long pos[MAXN]; n=N; m=M; k=K; for (long long i=0;i<m;i++) { long long x=R[i][0]; long long y=R[i][1]; long long z=L[i]; adj[x].push_back({y,z}); adj[y].push_back({x,z}); } for (long long i=0;i<MAXN;i++) { dist1[i]=LLONG_MAX; dist2[i]=LLONG_MAX; } priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> pq; for (long long i=0;i<k;i++) { niz[i+1]=P[i-1]; pq.push({0,niz[i+1]}); dist1[niz[i+1]]=0; dist2[niz[i+1]]=0; pos[niz[i+1]]=1; } while (pq.empty()==false) { long long node=pq.top().second; long long dist0=pq.top().first; pq.pop(); if (dist0>dist2[node0]) continue; if (pos[node]>1) continue; long long s=adj[node0].size(); for (long long i=0;i<s;i++) { long long node=adj[node0][i].first; long long dist=adj[node0][i].second; if (dist0+dist<dist1[node]) { dist2[node]=dist1[node]; dist1[node]=dist0+dist; pq.push({dist1[node],node}); } else if (dist0+dist<dist2[node]) { dist2[node]=dist0+dist; pq.push({dist2[node],node}); } } pos[node0]++; } return (int)dist2[0]; }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:11:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   11 |     vector<pair<long long long>> adj[MAXN];
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from crocodile.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
crocodile.cpp:11:12: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   11 |     vector<pair<long long long>> adj[MAXN];
      |            ^~~~
      |            std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from crocodile.cpp:2:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
crocodile.cpp:11:17: error: expected primary-expression before 'long'
   11 |     vector<pair<long long long>> adj[MAXN];
      |                 ^~~~
crocodile.cpp:22:9: error: 'adj' was not declared in this scope
   22 |         adj[x].push_back({y,z});
      |         ^~~
crocodile.cpp:30:5: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'?
   30 |     priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> pq;
      |     ^~~~~~~~~~~~~~
      |     std::priority_queue
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from crocodile.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:456:11: note: 'std::priority_queue' declared here
  456 |     class priority_queue
      |           ^~~~~~~~~~~~~~
crocodile.cpp:30:25: error: expected primary-expression before 'long'
   30 |     priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> pq;
      |                         ^~~~
crocodile.cpp:34:9: error: 'pq' was not declared in this scope
   34 |         pq.push({0,niz[i+1]});
      |         ^~
crocodile.cpp:39:12: error: 'pq' was not declared in this scope
   39 |     while (pq.empty()==false)
      |            ^~
crocodile.cpp:44:25: error: 'node0' was not declared in this scope; did you mean 'node'?
   44 |         if (dist0>dist2[node0]) continue;
      |                         ^~~~~
      |                         node
crocodile.cpp:46:21: error: 'adj' was not declared in this scope
   46 |         long long s=adj[node0].size();
      |                     ^~~
crocodile.cpp:46:25: error: 'node0' was not declared in this scope; did you mean 'node'?
   46 |         long long s=adj[node0].size();
      |                         ^~~~~
      |                         node