Submission #887977

# Submission time Handle Problem Language Result Execution time Memory
887977 2023-12-15T16:13:36 Z qrno Event Hopping (BOI22_events) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

vector<int> bfs(int source, vector<vector<int>> const& G) {
  int N = size(G);
  vector<int> dist(N, -1);

  queue<int> Q;
  dist[source] = 0;
  Q.push(source);

  while (!Q.empty()) {
    int v = Q.front(); Q.pop();
    for (auto u : G[v]) {
      if (dist[u] == -1) {
        Q.push(u);
        dist[u] = dist[v]+1;
      }
    }
  }

  return dist;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  int N, Q;
  cin >> N >> Q;

  vector<pair<int, int>> E(N);
  for (auto &[x, y] : E) cin >> x >> y;

  vector<vector<int>> G(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      if (E[j].first <= E[i].second && E[i].second <= E[j].second)
        G[i].push_back(j);
    }
  }

  while (Q--) {
    int v, u; cin >> v >> u; v--, u--;
    auto dist = bfs(v, G);
    if (dist[u] == -1) cout << "impossible" << endl;
    else cout << dist[u] << endl;
  }
}

Compilation message

events.cpp: In function 'std::vector<long long int> bfs(long long int, const std::vector<std::vector<long long int> >&)':
events.cpp:7:11: error: 'size' was not declared in this scope; did you mean 'dysize'?
    7 |   int N = size(G);
      |           ^~~~
      |           dysize
events.cpp: In function 'int main()':
events.cpp:34:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |   for (auto &[x, y] : E) cin >> x >> y;
      |              ^