Submission #960755

# Submission time Handle Problem Language Result Execution time Memory
960755 2024-04-11T02:47:14 Z Trisanu_Das Event Hopping (BOI22_events) C++17
10 / 100
1500 ms 30808 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;
    d[s] = 0;
    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 Correct 1 ms 348 KB Output is correct
2 Execution timed out 1586 ms 6048 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 5 ms 636 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 8 ms 1144 KB Output is correct
7 Correct 15 ms 2020 KB Output is correct
8 Correct 13 ms 3164 KB Output is correct
9 Correct 38 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 5 ms 636 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 8 ms 1144 KB Output is correct
7 Correct 15 ms 2020 KB Output is correct
8 Correct 13 ms 3164 KB Output is correct
9 Correct 38 ms 4440 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 456 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 4 ms 600 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 8 ms 1248 KB Output is correct
16 Correct 14 ms 1884 KB Output is correct
17 Correct 14 ms 3164 KB Output is correct
18 Correct 37 ms 4440 KB Output is correct
19 Execution timed out 1543 ms 30808 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 5 ms 636 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 8 ms 1144 KB Output is correct
7 Correct 15 ms 2020 KB Output is correct
8 Correct 13 ms 3164 KB Output is correct
9 Correct 38 ms 4440 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 10 ms 1116 KB Output is correct
16 Correct 14 ms 1884 KB Output is correct
17 Correct 13 ms 3164 KB Output is correct
18 Correct 37 ms 4444 KB Output is correct
19 Execution timed out 1545 ms 5728 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1512 ms 3920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Execution timed out 1586 ms 6048 KB Time limit exceeded
3 Halted 0 ms 0 KB -