답안 #824359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824359 2023-08-14T04:12:32 Z xink Passport (JOI23_passport) C++14
0 / 100
1 ms 228 KB
#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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 228 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 228 KB Output isn't correct
3 Halted 0 ms 0 KB -