# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
695307 |
2023-02-05T00:40:46 Z |
GusterGoose27 |
Jail (JOI22_jail) |
C++11 |
|
148 ms |
12364 KB |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int MAXN = 12e4;
vector<int> edges[MAXN];
int n, m;
pii queries[MAXN];
class query {
public:
int l, r;
bool f;
query(int l, int r, bool f) : l(l), r(r), f(f) {}
};
bool operator<(query &a, query &b) {
return (a.l == b.l) ? (a.r > b.r) : (a.l < b.l);
}
int main() {
int t; cin >> t;
bool s1 = 1;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) edges[i].clear();
for (int i = 0; i < n-1; i++) {
int x, y; cin >> x >> y;
x--; y--;
edges[x].push_back(y);
edges[y].push_back(x);
if (y-x != 1) s1 = 0;
}
cin >> m;
for (int i = 0; i < m; i++) {
int x, y; cin >> x >> y;
queries[i] = pii(x-1, y-1);
}
if (s1) {
vector<query> sorted;
for (int i = 0; i < m; i++) {
if (queries[i].first > queries[i].second) sorted.push_back(query(queries[i].second, queries[i].first, 1));
else sorted.push_back(query(queries[i].first, queries[i].second, 0));
}
sort(sorted.begin(), sorted.end());
int r[2];
r[0] = r[1] = -1;
bool ans = 1;
for (query q: sorted) {
if (r[q.f] >= q.r || r[!q.f] >= q.l) {
ans = 0;
break;
}
r[q.f] = q.r;
}
if (ans) {
cout << "Yes\n";
}
else cout << "No\n";
}
else assert(false);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
1 ms |
3028 KB |
Output is correct |
3 |
Correct |
2 ms |
3028 KB |
Output is correct |
4 |
Correct |
22 ms |
3396 KB |
Output is correct |
5 |
Correct |
46 ms |
3752 KB |
Output is correct |
6 |
Correct |
4 ms |
3156 KB |
Output is correct |
7 |
Correct |
4 ms |
3140 KB |
Output is correct |
8 |
Correct |
4 ms |
3156 KB |
Output is correct |
9 |
Correct |
64 ms |
4452 KB |
Output is correct |
10 |
Correct |
74 ms |
8312 KB |
Output is correct |
11 |
Correct |
12 ms |
3284 KB |
Output is correct |
12 |
Correct |
55 ms |
3996 KB |
Output is correct |
13 |
Correct |
100 ms |
10144 KB |
Output is correct |
14 |
Correct |
100 ms |
10096 KB |
Output is correct |
15 |
Correct |
102 ms |
10072 KB |
Output is correct |
16 |
Correct |
148 ms |
12228 KB |
Output is correct |
17 |
Correct |
109 ms |
10328 KB |
Output is correct |
18 |
Correct |
144 ms |
12364 KB |
Output is correct |
19 |
Correct |
106 ms |
10276 KB |
Output is correct |
20 |
Correct |
110 ms |
10388 KB |
Output is correct |
21 |
Correct |
104 ms |
10336 KB |
Output is correct |
22 |
Correct |
110 ms |
10324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
4 ms |
3156 KB |
Output is correct |
4 |
Runtime error |
4 ms |
6228 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
4 ms |
3156 KB |
Output is correct |
4 |
Runtime error |
4 ms |
6228 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
4 ms |
3156 KB |
Output is correct |
4 |
Runtime error |
4 ms |
6228 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
4 ms |
3156 KB |
Output is correct |
4 |
Runtime error |
4 ms |
6228 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Runtime error |
5 ms |
6100 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
1 ms |
3028 KB |
Output is correct |
3 |
Correct |
2 ms |
3028 KB |
Output is correct |
4 |
Correct |
22 ms |
3396 KB |
Output is correct |
5 |
Correct |
46 ms |
3752 KB |
Output is correct |
6 |
Correct |
4 ms |
3156 KB |
Output is correct |
7 |
Correct |
4 ms |
3140 KB |
Output is correct |
8 |
Correct |
4 ms |
3156 KB |
Output is correct |
9 |
Correct |
64 ms |
4452 KB |
Output is correct |
10 |
Correct |
74 ms |
8312 KB |
Output is correct |
11 |
Correct |
12 ms |
3284 KB |
Output is correct |
12 |
Correct |
55 ms |
3996 KB |
Output is correct |
13 |
Correct |
100 ms |
10144 KB |
Output is correct |
14 |
Correct |
100 ms |
10096 KB |
Output is correct |
15 |
Correct |
102 ms |
10072 KB |
Output is correct |
16 |
Correct |
148 ms |
12228 KB |
Output is correct |
17 |
Correct |
109 ms |
10328 KB |
Output is correct |
18 |
Correct |
144 ms |
12364 KB |
Output is correct |
19 |
Correct |
106 ms |
10276 KB |
Output is correct |
20 |
Correct |
110 ms |
10388 KB |
Output is correct |
21 |
Correct |
104 ms |
10336 KB |
Output is correct |
22 |
Correct |
110 ms |
10324 KB |
Output is correct |
23 |
Correct |
2 ms |
3028 KB |
Output is correct |
24 |
Correct |
2 ms |
3028 KB |
Output is correct |
25 |
Correct |
4 ms |
3156 KB |
Output is correct |
26 |
Runtime error |
4 ms |
6228 KB |
Execution killed with signal 6 |
27 |
Halted |
0 ms |
0 KB |
- |