Submission #1260914

#TimeUsernameProblemLanguageResultExecution timeMemory
1260914patgraPassport (JOI23_passport)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h> #define rep(a,b,c) for(auto a = (b); a != (c); a++) #define repD(a,b,c) for(auto a = (b); a != (c); a--) #define repIn(a, b) for(auto& a : (b)) #define repIn2(a, b, c) for(auto& [a, b] : (c)) constexpr bool dbg = 1; #define DEBUG if constexpr(dbg) #define DC DEBUG std::cerr #define eol std::endl #define ll long long #define pb push_back using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector<pair<int, int>> v(n); rep(i, 0, n) cin >> v[i].first >> v[i].second; int q; rep(i, 0, q) { int l, r; cin >> l; l--; r = l; if(l == 0) { int ans = 0; vector<int> maxPref; rep(i, 0, n) maxPref.pb(max(maxPref.size() ? maxPref.back() : 0, v[i].second)); while(r != n - 1 && r < maxPref[r]) { ans++; r = maxPref[r]; } if(r != n - 1) ans = -1; cout << ans << '\n'; } } }
#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...