# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
630203 |
2022-08-16T02:17:17 Z |
flappybird |
Jail (JOI22_jail) |
C++17 |
|
5000 ms |
10068 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 101010
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
vector<int> adj[MAX];
vector<int> graph[MAX];
int S[MAX];
int T[MAX];
int deg[MAX];
bool chk(int x, int ban, int e, int p = 0) {
if (x == ban) return false;
if (x == e) return true;
for (auto v : adj[x]) {
if (v == p) continue;
if (v == ban) continue;
if (chk(v, ban, e, x)) return true;
}
return false;
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int Q;
cin >> Q;
while (Q--) {
int N;
cin >> N;
int i, a, b;
for (i = 1; i <= N; i++) adj[i].clear();
for (i = 1; i < N; i++) cin >> a >> b, adj[a].push_back(b), adj[b].push_back(a);
int M;
cin >> M;
for (i = 1; i <= M; i++) cin >> S[i] >> T[i], deg[i] = 0, graph[i].clear();
int j;
for (i = 1; i <= M; i++) {
for (j = 1; j <= M; j++) {
if (i == j) continue;
int a, b, c;
a = S[i];
b = T[i];
c = T[j];
if (!chk(a, c, b)) {
graph[i].push_back(j);
deg[j]++;
}
}
}
for (i = 1; i <= M; i++) {
for (j = 1; j <= M; j++) {
if (i == j) continue;
int a, b, c;
a = S[i];
b = T[i];
c = S[j];
if (!chk(a, c, b)) {
graph[j].push_back(i);
deg[i]++;
}
}
}
int cnt = 0;
queue<int> q;
for (i = 1; i <= M; i++) if (!deg[i]) q.push(i);
while (q.size()) {
int t = q.front();
cnt++;
q.pop();
for (auto v : graph[t]) {
deg[v]--;
if (!deg[v]) q.push(v);
}
}
if (cnt == M) cout << "Yes" << ln;
else cout << "No" << ln;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
2 ms |
5080 KB |
Output is correct |
4 |
Correct |
14 ms |
5412 KB |
Output is correct |
5 |
Correct |
25 ms |
5708 KB |
Output is correct |
6 |
Correct |
4 ms |
5076 KB |
Output is correct |
7 |
Correct |
4 ms |
5076 KB |
Output is correct |
8 |
Correct |
189 ms |
5196 KB |
Output is correct |
9 |
Execution timed out |
5071 ms |
5868 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
4 ms |
5076 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
4 ms |
5076 KB |
Output is correct |
7 |
Correct |
4 ms |
5076 KB |
Output is correct |
8 |
Correct |
4 ms |
5084 KB |
Output is correct |
9 |
Correct |
4 ms |
5076 KB |
Output is correct |
10 |
Correct |
4 ms |
5076 KB |
Output is correct |
11 |
Correct |
4 ms |
5088 KB |
Output is correct |
12 |
Correct |
5 ms |
5080 KB |
Output is correct |
13 |
Correct |
3 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
4 ms |
5076 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
4 ms |
5076 KB |
Output is correct |
7 |
Correct |
4 ms |
5076 KB |
Output is correct |
8 |
Correct |
4 ms |
5084 KB |
Output is correct |
9 |
Correct |
4 ms |
5076 KB |
Output is correct |
10 |
Correct |
4 ms |
5076 KB |
Output is correct |
11 |
Correct |
4 ms |
5088 KB |
Output is correct |
12 |
Correct |
5 ms |
5080 KB |
Output is correct |
13 |
Correct |
3 ms |
5076 KB |
Output is correct |
14 |
Correct |
3 ms |
5072 KB |
Output is correct |
15 |
Correct |
3 ms |
5076 KB |
Output is correct |
16 |
Correct |
4 ms |
5076 KB |
Output is correct |
17 |
Correct |
5 ms |
5076 KB |
Output is correct |
18 |
Correct |
6 ms |
5076 KB |
Output is correct |
19 |
Correct |
3 ms |
5076 KB |
Output is correct |
20 |
Correct |
5 ms |
5076 KB |
Output is correct |
21 |
Correct |
6 ms |
5204 KB |
Output is correct |
22 |
Correct |
4 ms |
5084 KB |
Output is correct |
23 |
Correct |
3 ms |
5076 KB |
Output is correct |
24 |
Correct |
3 ms |
5076 KB |
Output is correct |
25 |
Correct |
5 ms |
5076 KB |
Output is correct |
26 |
Correct |
3 ms |
5076 KB |
Output is correct |
27 |
Correct |
5 ms |
5084 KB |
Output is correct |
28 |
Correct |
3 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
4 ms |
5076 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
4 ms |
5076 KB |
Output is correct |
7 |
Correct |
4 ms |
5076 KB |
Output is correct |
8 |
Correct |
4 ms |
5084 KB |
Output is correct |
9 |
Correct |
4 ms |
5076 KB |
Output is correct |
10 |
Correct |
4 ms |
5076 KB |
Output is correct |
11 |
Correct |
4 ms |
5088 KB |
Output is correct |
12 |
Correct |
5 ms |
5080 KB |
Output is correct |
13 |
Correct |
3 ms |
5076 KB |
Output is correct |
14 |
Correct |
3 ms |
5072 KB |
Output is correct |
15 |
Correct |
3 ms |
5076 KB |
Output is correct |
16 |
Correct |
4 ms |
5076 KB |
Output is correct |
17 |
Correct |
5 ms |
5076 KB |
Output is correct |
18 |
Correct |
6 ms |
5076 KB |
Output is correct |
19 |
Correct |
3 ms |
5076 KB |
Output is correct |
20 |
Correct |
5 ms |
5076 KB |
Output is correct |
21 |
Correct |
6 ms |
5204 KB |
Output is correct |
22 |
Correct |
4 ms |
5084 KB |
Output is correct |
23 |
Correct |
3 ms |
5076 KB |
Output is correct |
24 |
Correct |
3 ms |
5076 KB |
Output is correct |
25 |
Correct |
5 ms |
5076 KB |
Output is correct |
26 |
Correct |
3 ms |
5076 KB |
Output is correct |
27 |
Correct |
5 ms |
5084 KB |
Output is correct |
28 |
Correct |
3 ms |
5076 KB |
Output is correct |
29 |
Correct |
206 ms |
5312 KB |
Output is correct |
30 |
Correct |
136 ms |
5132 KB |
Output is correct |
31 |
Correct |
113 ms |
5140 KB |
Output is correct |
32 |
Correct |
75 ms |
5132 KB |
Output is correct |
33 |
Correct |
13 ms |
5132 KB |
Output is correct |
34 |
Correct |
212 ms |
5128 KB |
Output is correct |
35 |
Correct |
197 ms |
5164 KB |
Output is correct |
36 |
Correct |
156 ms |
5124 KB |
Output is correct |
37 |
Correct |
99 ms |
5112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
4 ms |
5076 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
4 ms |
5076 KB |
Output is correct |
7 |
Correct |
4 ms |
5076 KB |
Output is correct |
8 |
Correct |
4 ms |
5084 KB |
Output is correct |
9 |
Correct |
4 ms |
5076 KB |
Output is correct |
10 |
Correct |
4 ms |
5076 KB |
Output is correct |
11 |
Correct |
4 ms |
5088 KB |
Output is correct |
12 |
Correct |
5 ms |
5080 KB |
Output is correct |
13 |
Correct |
3 ms |
5076 KB |
Output is correct |
14 |
Correct |
3 ms |
5072 KB |
Output is correct |
15 |
Correct |
3 ms |
5076 KB |
Output is correct |
16 |
Correct |
4 ms |
5076 KB |
Output is correct |
17 |
Correct |
5 ms |
5076 KB |
Output is correct |
18 |
Correct |
6 ms |
5076 KB |
Output is correct |
19 |
Correct |
3 ms |
5076 KB |
Output is correct |
20 |
Correct |
5 ms |
5076 KB |
Output is correct |
21 |
Correct |
6 ms |
5204 KB |
Output is correct |
22 |
Correct |
4 ms |
5084 KB |
Output is correct |
23 |
Correct |
3 ms |
5076 KB |
Output is correct |
24 |
Correct |
3 ms |
5076 KB |
Output is correct |
25 |
Correct |
5 ms |
5076 KB |
Output is correct |
26 |
Correct |
3 ms |
5076 KB |
Output is correct |
27 |
Correct |
5 ms |
5084 KB |
Output is correct |
28 |
Correct |
3 ms |
5076 KB |
Output is correct |
29 |
Correct |
206 ms |
5312 KB |
Output is correct |
30 |
Correct |
136 ms |
5132 KB |
Output is correct |
31 |
Correct |
113 ms |
5140 KB |
Output is correct |
32 |
Correct |
75 ms |
5132 KB |
Output is correct |
33 |
Correct |
13 ms |
5132 KB |
Output is correct |
34 |
Correct |
212 ms |
5128 KB |
Output is correct |
35 |
Correct |
197 ms |
5164 KB |
Output is correct |
36 |
Correct |
156 ms |
5124 KB |
Output is correct |
37 |
Correct |
99 ms |
5112 KB |
Output is correct |
38 |
Execution timed out |
5081 ms |
5860 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
3 ms |
5076 KB |
Output is correct |
5 |
Correct |
14 ms |
5228 KB |
Output is correct |
6 |
Correct |
4 ms |
5084 KB |
Output is correct |
7 |
Correct |
3 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
5076 KB |
Output is correct |
9 |
Correct |
3 ms |
5076 KB |
Output is correct |
10 |
Correct |
3 ms |
5076 KB |
Output is correct |
11 |
Correct |
3 ms |
5076 KB |
Output is correct |
12 |
Correct |
165 ms |
5108 KB |
Output is correct |
13 |
Correct |
1175 ms |
5792 KB |
Output is correct |
14 |
Correct |
578 ms |
5940 KB |
Output is correct |
15 |
Correct |
982 ms |
5704 KB |
Output is correct |
16 |
Runtime error |
10 ms |
10068 KB |
Execution killed with signal 11 |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
2 ms |
5080 KB |
Output is correct |
4 |
Correct |
14 ms |
5412 KB |
Output is correct |
5 |
Correct |
25 ms |
5708 KB |
Output is correct |
6 |
Correct |
4 ms |
5076 KB |
Output is correct |
7 |
Correct |
4 ms |
5076 KB |
Output is correct |
8 |
Correct |
189 ms |
5196 KB |
Output is correct |
9 |
Execution timed out |
5071 ms |
5868 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |