#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define X first
#define Y second
#define sep ' '
#define endl '\n'
#define debug(x) cerr << #x << ": " << x << endl;
const ll MAXN = 1e6 + 10;
int n, m;
inline int solve() {
cin >> n;
for (int i = 1; i < n; i++) {
int u, v;
cin >> u >> v;
}
cin >> m;
vector<pll> vec;
for (int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
vec.push_back({u, v});
}
sort(all(vec));
for (auto& e : vec)
swap(e.X, e.Y);
return cout << (is_sorted(all(vec)) ? "Yes" : "No") << endl, 0;
return 0;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int q;
cin >> q;
while (q--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
7 ms |
660 KB |
Output is correct |
5 |
Correct |
13 ms |
1076 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
376 KB |
Output is correct |
9 |
Correct |
17 ms |
1464 KB |
Output is correct |
10 |
Correct |
16 ms |
1712 KB |
Output is correct |
11 |
Correct |
4 ms |
468 KB |
Output is correct |
12 |
Correct |
20 ms |
1276 KB |
Output is correct |
13 |
Correct |
26 ms |
3484 KB |
Output is correct |
14 |
Correct |
24 ms |
3488 KB |
Output is correct |
15 |
Correct |
28 ms |
3404 KB |
Output is correct |
16 |
Correct |
44 ms |
5144 KB |
Output is correct |
17 |
Correct |
27 ms |
3524 KB |
Output is correct |
18 |
Correct |
37 ms |
5152 KB |
Output is correct |
19 |
Correct |
27 ms |
3528 KB |
Output is correct |
20 |
Correct |
29 ms |
3624 KB |
Output is correct |
21 |
Correct |
30 ms |
3484 KB |
Output is correct |
22 |
Correct |
27 ms |
3528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Incorrect |
1 ms |
356 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Incorrect |
1 ms |
356 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Incorrect |
1 ms |
356 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Incorrect |
1 ms |
356 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
7 ms |
660 KB |
Output is correct |
5 |
Correct |
13 ms |
1076 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
376 KB |
Output is correct |
9 |
Correct |
17 ms |
1464 KB |
Output is correct |
10 |
Correct |
16 ms |
1712 KB |
Output is correct |
11 |
Correct |
4 ms |
468 KB |
Output is correct |
12 |
Correct |
20 ms |
1276 KB |
Output is correct |
13 |
Correct |
26 ms |
3484 KB |
Output is correct |
14 |
Correct |
24 ms |
3488 KB |
Output is correct |
15 |
Correct |
28 ms |
3404 KB |
Output is correct |
16 |
Correct |
44 ms |
5144 KB |
Output is correct |
17 |
Correct |
27 ms |
3524 KB |
Output is correct |
18 |
Correct |
37 ms |
5152 KB |
Output is correct |
19 |
Correct |
27 ms |
3528 KB |
Output is correct |
20 |
Correct |
29 ms |
3624 KB |
Output is correct |
21 |
Correct |
30 ms |
3484 KB |
Output is correct |
22 |
Correct |
27 ms |
3528 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
360 KB |
Output is correct |
26 |
Incorrect |
1 ms |
356 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |