#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;
#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);}
#else
#define debug(...) 7122
#endif
#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second
const int SIZE = 12e4 + 5;
int n, m;
tuple<int, int, int> p[SIZE];
void solve() {
cin >> n;
FOR (i, 2, n) {
int a, b;
cin >> a >> b;
}
cin >> m;
FOR (i, 1, m) {
int l, r;
cin >> l >> r;
p[i] = {min(l, r), max(l, r), l > r};
}
sort(p + 1, p + m + 1);
int last = 0, t;
FOR (i, 1, m) {
auto [l, r, ty] = p[i];
if (r <= last) {
cout << "No\n";
return;
}
if (l <= last && ty != t) {
cout << "No\n";
return;
}
last = r;
t = ty;
}
cout << "Yes\n";
}
int main() {
Waimai;
int tt;
cin >> tt;
while (tt--) solve();
}
Compilation message
jail.cpp: In function 'void solve()':
jail.cpp:47:23: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
47 | if (l <= last && ty != t) {
| ~~~~~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
9 ms |
340 KB |
Output is correct |
5 |
Correct |
12 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
15 ms |
340 KB |
Output is correct |
10 |
Correct |
15 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
16 ms |
212 KB |
Output is correct |
13 |
Correct |
23 ms |
848 KB |
Output is correct |
14 |
Correct |
23 ms |
848 KB |
Output is correct |
15 |
Correct |
26 ms |
844 KB |
Output is correct |
16 |
Correct |
42 ms |
1712 KB |
Output is correct |
17 |
Correct |
24 ms |
972 KB |
Output is correct |
18 |
Correct |
36 ms |
1612 KB |
Output is correct |
19 |
Correct |
28 ms |
976 KB |
Output is correct |
20 |
Correct |
26 ms |
1000 KB |
Output is correct |
21 |
Correct |
25 ms |
964 KB |
Output is correct |
22 |
Correct |
25 ms |
964 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 |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 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 |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 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 |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 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 |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
6 ms |
212 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 |
9 ms |
340 KB |
Output is correct |
5 |
Correct |
12 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
15 ms |
340 KB |
Output is correct |
10 |
Correct |
15 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
16 ms |
212 KB |
Output is correct |
13 |
Correct |
23 ms |
848 KB |
Output is correct |
14 |
Correct |
23 ms |
848 KB |
Output is correct |
15 |
Correct |
26 ms |
844 KB |
Output is correct |
16 |
Correct |
42 ms |
1712 KB |
Output is correct |
17 |
Correct |
24 ms |
972 KB |
Output is correct |
18 |
Correct |
36 ms |
1612 KB |
Output is correct |
19 |
Correct |
28 ms |
976 KB |
Output is correct |
20 |
Correct |
26 ms |
1000 KB |
Output is correct |
21 |
Correct |
25 ms |
964 KB |
Output is correct |
22 |
Correct |
25 ms |
964 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 |
212 KB |
Output is correct |
26 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |