# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
887334 | 2023-12-14T09:18:19 Z | HossamHero7 | Passport (JOI23_passport) | C++14 | 2000 ms | 1048576 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' void solve(){ int n; cin>>n; vector<pair<int,int>> v(n); for(auto &[a,b] : v) cin>>a>>b , a -- , b--; int q; cin>>q; while(q--){ int x; cin>>x; x --; queue<pair<int,int>> q; q.push({x,x}); vector<vector<int>> dep(n,vector<int>(n)); vector<vector<bool>> vis(n,vector<bool>(n)); vis[x][x] = 1; while(q.size()){ auto [l,r] = q.front(); q.pop(); for(int i=l;i<=r;i++){ int L = min(l , v[i].first); int R = max(r , v[i].second); if(vis[L][R]) continue; q.push({L,R}); vis[L][R] = 1; dep[L][R] = dep[l][r] + 1; } } if(vis[0][n-1]) cout<<dep[0][n-1]<<endl; else cout<<-1<<endl; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; //cin>>t; while(t--){ solve(); } return 0; }
Compilation message
# | 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 | 0 ms | 348 KB | Output is correct |
4 | Runtime error | 721 ms | 1048576 KB | Execution killed with signal 9 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 456 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 712 KB | Output is correct |
12 | Correct | 3 ms | 604 KB | Output is correct |
13 | Correct | 1 ms | 604 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 3 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 456 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 712 KB | Output is correct |
12 | Correct | 3 ms | 604 KB | Output is correct |
13 | Correct | 1 ms | 604 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 3 ms | 604 KB | Output is correct |
16 | Correct | 1292 ms | 24500 KB | Output is correct |
17 | Correct | 1088 ms | 25436 KB | Output is correct |
18 | Correct | 27 ms | 25944 KB | Output is correct |
19 | Correct | 43 ms | 24600 KB | Output is correct |
20 | Execution timed out | 2029 ms | 25956 KB | Time limit exceeded |
21 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 456 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 712 KB | Output is correct |
12 | Correct | 3 ms | 604 KB | Output is correct |
13 | Correct | 1 ms | 604 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 3 ms | 604 KB | Output is correct |
16 | Correct | 1292 ms | 24500 KB | Output is correct |
17 | Correct | 1088 ms | 25436 KB | Output is correct |
18 | Correct | 27 ms | 25944 KB | Output is correct |
19 | Correct | 43 ms | 24600 KB | Output is correct |
20 | Execution timed out | 2029 ms | 25956 KB | Time limit exceeded |
21 | 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 | 0 ms | 348 KB | Output is correct |
4 | Runtime error | 721 ms | 1048576 KB | Execution killed with signal 9 |
5 | Halted | 0 ms | 0 KB | - |