Submission #824359

#TimeUsernameProblemLanguageResultExecution timeMemory
824359xinkPassport (JOI23_passport)C++14
0 / 100
1 ms228 KiB
#include <iostream> #include <vector> #include <utility> #include <sstream> #include <climits> #include <cstring> #define ll long long #define ld long double using namespace std; const ll mod = 1e9 + 7; const int maxn = 2e5 + 5; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; ii range[maxn]; void solve() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> range[i].first >> range[i].second; range[i].first--, range[i].second--; } int q; cin >> q; while (q-- > 0) { int idx; cin >> idx; if (idx == 1) { int r = 0, cnt = 1; while (r < n && range[r].second != r) { r = range[r].second; cnt++; } cout << cnt << '\n'; } } } int main() { // freopen("input_text", "r", stdin); // freopen("output_text", "w", stdout); // ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t-- > 0) solve(); }
#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...