#include <bits/stdc++.h>
using namespace std;/*
<<<<It's never too late for a new beginning in your life>>>>
Today is hard
tomorrow will worse
but the day after tomorrow will be the sunshine..
HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD............
Never give up */
//The most CHALISHKANCHIK
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vii;
const long long N = 1e5+50, inf = 1e18, mod = 1e9+7;
void solve(){
int n;cin >> n;
for(int i = 0, a, b; i < n-1; i++){
cin >> a >> b;
}
int m;
cin >> m;
vii p(m);
for(auto &[i, j]:p)cin >> i >> j;
sort(all(p));
set<int> st;
for(int i = m-1; i >= 0; i--){
if(!st.empty() && *st.begin() < p[i].ss){
cout << "No\n";
return;
}
st.insert(p[i].ss);
}
cout << "Yes\n";
}
main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int t = 1;
cin >> t;
while(t--){
solve();
}
}
Compilation message
jail.cpp:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
41 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
348 KB |
Output is correct |
5 |
Correct |
11 ms |
452 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
13 ms |
1108 KB |
Output is correct |
10 |
Correct |
13 ms |
1360 KB |
Output is correct |
11 |
Correct |
3 ms |
604 KB |
Output is correct |
12 |
Correct |
14 ms |
1236 KB |
Output is correct |
13 |
Correct |
26 ms |
4692 KB |
Output is correct |
14 |
Correct |
20 ms |
2388 KB |
Output is correct |
15 |
Correct |
22 ms |
2388 KB |
Output is correct |
16 |
Correct |
36 ms |
3928 KB |
Output is correct |
17 |
Correct |
28 ms |
5456 KB |
Output is correct |
18 |
Correct |
46 ms |
9584 KB |
Output is correct |
19 |
Correct |
29 ms |
5480 KB |
Output is correct |
20 |
Correct |
28 ms |
4444 KB |
Output is correct |
21 |
Correct |
23 ms |
2652 KB |
Output is correct |
22 |
Correct |
29 ms |
5464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Incorrect |
1 ms |
472 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
348 KB |
Output is correct |
5 |
Correct |
11 ms |
452 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
13 ms |
1108 KB |
Output is correct |
10 |
Correct |
13 ms |
1360 KB |
Output is correct |
11 |
Correct |
3 ms |
604 KB |
Output is correct |
12 |
Correct |
14 ms |
1236 KB |
Output is correct |
13 |
Correct |
26 ms |
4692 KB |
Output is correct |
14 |
Correct |
20 ms |
2388 KB |
Output is correct |
15 |
Correct |
22 ms |
2388 KB |
Output is correct |
16 |
Correct |
36 ms |
3928 KB |
Output is correct |
17 |
Correct |
28 ms |
5456 KB |
Output is correct |
18 |
Correct |
46 ms |
9584 KB |
Output is correct |
19 |
Correct |
29 ms |
5480 KB |
Output is correct |
20 |
Correct |
28 ms |
4444 KB |
Output is correct |
21 |
Correct |
23 ms |
2652 KB |
Output is correct |
22 |
Correct |
29 ms |
5464 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |