Submission #926348

#TimeUsernameProblemLanguageResultExecution timeMemory
926348OAleksaPassport (JOI23_passport)C++14
6 / 100
24 ms7512 KiB
#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; int ans = 1, ptr = r[1]; while (ptr != n) { if (ptr == p[r[ptr]]) { ans = -1; break; } ptr = p[ptr]; ++ans; } cout << ans << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...