#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
void solve(){
int n;cin>>n;
for(int i=0;i<n-1;i++){
int a,b;cin>>a>>b;
}
vector<pair<int,int> > arr;
int m;cin>>m;
for(int i=0;i<m;i++){
int s,t;cin>>s>>t;
arr.push_back({s,t});
}
sort(arr.begin(),arr.end());
for(int i=1;i<m;i++){
if(arr[i].second<arr[i-1].second){
cout<<"No\n";
return;
}
}
cout<<"Yes\n";
return ;
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int q;cin>>q;
while(q--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
604 KB |
Output is correct |
5 |
Correct |
11 ms |
1076 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
472 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
13 ms |
1468 KB |
Output is correct |
10 |
Correct |
14 ms |
1884 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
14 ms |
1372 KB |
Output is correct |
13 |
Correct |
21 ms |
3032 KB |
Output is correct |
14 |
Correct |
20 ms |
3132 KB |
Output is correct |
15 |
Correct |
26 ms |
3104 KB |
Output is correct |
16 |
Correct |
47 ms |
4200 KB |
Output is correct |
17 |
Correct |
22 ms |
3040 KB |
Output is correct |
18 |
Correct |
29 ms |
4120 KB |
Output is correct |
19 |
Correct |
26 ms |
3032 KB |
Output is correct |
20 |
Correct |
22 ms |
3028 KB |
Output is correct |
21 |
Correct |
24 ms |
3376 KB |
Output is correct |
22 |
Correct |
23 ms |
3128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
604 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
604 KB |
Output is correct |
5 |
Correct |
11 ms |
1076 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
472 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
13 ms |
1468 KB |
Output is correct |
10 |
Correct |
14 ms |
1884 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
14 ms |
1372 KB |
Output is correct |
13 |
Correct |
21 ms |
3032 KB |
Output is correct |
14 |
Correct |
20 ms |
3132 KB |
Output is correct |
15 |
Correct |
26 ms |
3104 KB |
Output is correct |
16 |
Correct |
47 ms |
4200 KB |
Output is correct |
17 |
Correct |
22 ms |
3040 KB |
Output is correct |
18 |
Correct |
29 ms |
4120 KB |
Output is correct |
19 |
Correct |
26 ms |
3032 KB |
Output is correct |
20 |
Correct |
22 ms |
3028 KB |
Output is correct |
21 |
Correct |
24 ms |
3376 KB |
Output is correct |
22 |
Correct |
23 ms |
3128 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |