Submission #926346

# Submission time Handle Problem Language Result Execution time Memory
926346 2024-02-12T20:11:29 Z OAleksa Passport (JOI23_passport) C++14
0 / 100
1 ms 4444 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
const int N = 2e5 + 69;
int n, l[N], r[N], q, p[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n;
  	for (int i = 1;i <= n;i++) {
  		cin >> l[i] >> r[i];
  		p[i] = max(p[i - 1], r[i]);
  	}
  	cin >> q;
  	for (int i = 1;i <= q;i++) {
  		int x;
  		cin >> x;
  		assert(x == 1);
  		int ans = 1, ptr = 1;
  		while (ptr != n) {
  			if (ptr == p[r[ptr]]) {
  				ans = -1;
  				break;
  			}
  			ptr = p[r[ptr]];
  			if (ptr == n)
  				break;
  			++ans;
  		}
  		cout << ans << '\n';
  	}
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -