Submission #1099131

# Submission time Handle Problem Language Result Execution time Memory
1099131 2024-10-10T15:32:09 Z akamizane Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
using ll = long long;
using pii = pair<int,long long>;
 
#define el cout << '\n'
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
template <class T1, class T2>bool chmax(T1 &a, T2 b){if (a < b) {a = b; return true;}return false;}
template <class T1, class T2>bool chmin(T1 &a, T2 b){if (a > b) {a = b; return true;}return false;}

ll travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
  int n, m, k;
  n = N, m = M, k = K;
  vector<vector<pair<int,long long>>> ad(n);
  REP(i, m){
    int u, v, w;
    u = R[i][0], v = R[i][1], w = L[i];
    ad[u].pb({v, w});
    ad[v].pb({u, w});
  }
  vector<vector<ll>> d(n, vector<ll> (2, 1e18));
  using T = pair<long long, int>;
  priority_queue<T, vector<T>, greater<T>> pq;
  REP(i, k){
    int p;
    p = P[i];
    d[p][0] = d[p][1] = 0;
    pq.push({0, p});
  }
  while(pq.size()){
    auto [val, u] = pq.top();
    pq.pop();
    if (val != d[u][1]) continue;
    for (auto [v, w] : ad[u]){
      if (val + w < d[v][0]){
        if (d[v][0] != d[v][1] && d[v][0] < 1e18){
          d[v][1] = d[v][0];
          pq.push({d[v][1], v});
        }
        d[v][0] = val + w;
      }
      else if (val + w < d[v][1]){
        d[v][1] = val + w;
        pq.push({d[v][1], v});
      }
    }
  }
  return d[0][1];
}

Compilation message

crocodile.cpp:2:13: error: 'pair' does not name a type
    2 | using pii = pair<int,long long>;
      |             ^~~~
crocodile.cpp: In function 'll travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:18:3: error: 'vector' was not declared in this scope
   18 |   vector<vector<pair<int,long long>>> ad(n);
      |   ^~~~~~
crocodile.cpp:18:17: error: 'pair' was not declared in this scope
   18 |   vector<vector<pair<int,long long>>> ad(n);
      |                 ^~~~
crocodile.cpp:18:22: error: expected primary-expression before 'int'
   18 |   vector<vector<pair<int,long long>>> ad(n);
      |                      ^~~
crocodile.cpp:22:5: error: 'ad' was not declared in this scope
   22 |     ad[u].pb({v, w});
      |     ^~
crocodile.cpp:25:19: error: expected primary-expression before '>>' token
   25 |   vector<vector<ll>> d(n, vector<ll> (2, 1e18));
      |                   ^~
crocodile.cpp:25:36: error: expected primary-expression before '>' token
   25 |   vector<vector<ll>> d(n, vector<ll> (2, 1e18));
      |                                    ^
crocodile.cpp:25:39: warning: left operand of comma operator has no effect [-Wunused-value]
   25 |   vector<vector<ll>> d(n, vector<ll> (2, 1e18));
      |                                       ^
crocodile.cpp:25:22: error: 'd' was not declared in this scope
   25 |   vector<vector<ll>> d(n, vector<ll> (2, 1e18));
      |                      ^
crocodile.cpp:26:13: error: 'pair' does not name a type
   26 |   using T = pair<long long, int>;
      |             ^~~~
crocodile.cpp:27:3: error: 'priority_queue' was not declared in this scope
   27 |   priority_queue<T, vector<T>, greater<T>> pq;
      |   ^~~~~~~~~~~~~~
crocodile.cpp:27:18: error: 'T' was not declared in this scope
   27 |   priority_queue<T, vector<T>, greater<T>> pq;
      |                  ^
crocodile.cpp:27:30: error: expected primary-expression before ',' token
   27 |   priority_queue<T, vector<T>, greater<T>> pq;
      |                              ^
crocodile.cpp:27:32: error: 'greater' was not declared in this scope
   27 |   priority_queue<T, vector<T>, greater<T>> pq;
      |                                ^~~~~~~
crocodile.cpp:27:44: error: 'pq' was not declared in this scope; did you mean 'pb'?
   27 |   priority_queue<T, vector<T>, greater<T>> pq;
      |                                            ^~
      |                                            pb
crocodile.cpp:38:24: error: 'ad' was not declared in this scope
   38 |     for (auto [v, w] : ad[u]){
      |                        ^~