#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++;
}
if (r == n)
cout << cnt << '\n';
else
cout << -1 << '\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 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |