Submission #960753

# Submission time Handle Problem Language Result Execution time Memory
960753 2024-04-11T02:46:25 Z Trisanu_Das Event Hopping (BOI22_events) C++17
0 / 100
1500 ms 6064 KB
#include <bits/stdc++.h>
using namespace std;
#define S first
#define E second

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  
  int n, q; cin >> n >> q;
  pair<int, int> ev[n];
  for(int i = 0; i < n; i++) cin >> ev[i].S >> ev[i].E;
  vector<int> adj[n];
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      if(i != j && ev[j].S <= ev[i].E && ev[i].E <= ev[j].E) adj[i].push_back(j);
  
  while(q--){
    int s, e; cin >> s >> e; s--; e--;
    vector<int> d(n, -1); queue<int> q;
    q.push(s);
    while(!q.empty()){
      int u = q.front(); q.pop();
      if(u == e) break;
      for(int v : adj[u]){
        if(d[v] != -1) continue;
        d[v] = d[u] + 1;
        q.push(v);
      }
    }
    if(d[e] == -1) cout << "impossible\n";
    else cout << d[e] << '\n';
  }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1557 ms 6064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -