# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
815180 | 2023-08-08T12:58:23 Z | waldi | Jail (JOI22_jail) | C++17 | 5000 ms | 17660 KB |
#include<bits/stdc++.h> #define FOR(i,p,k) for(int i=(p);i<=(k);++i) #define REP(i,n) FOR(i,0,(n)-1) #define pii pair<int, int> #define fi first #define se second using namespace std; int main(){ int q; scanf("%d", &q); while(q--){ int n; scanf("%d", &n); vector<vector<int>> g(n+1); for(int i = n; --i;){ int a, b; scanf("%d%d", &a, &b); g[a].emplace_back(b); g[b].emplace_back(a); } int m; scanf("%d", &m); vector<pii> trasy(m); vector<bool> czy(n+1, 0); REP(i, m) scanf("%d%d", &trasy[i].fi, &trasy[i].se), czy[trasy[i].fi] = 1; bool wyn = 1; REP(ile, m){ bool ruch = 0; REP(i, m) if(czy[trasy[i].fi]){ bool git = 0; function<void(int, int)> dfs = [&](int w, int o){ if(czy[w] && w != trasy[i].fi) return; if(w == trasy[i].se) git = 1; for(int x : g[w]) if(x != o) dfs(x, w); }; dfs(trasy[i].fi, 0); if(git){ czy[trasy[i].fi] = 0; czy[trasy[i].se] = 1; ruch = 1; break; } } if(!ruch){wyn = 0; break;} } printf(wyn ? "Yes\n" : "No\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 13 ms | 312 KB | Output is correct |
5 | Correct | 27 ms | 948 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Correct | 3 ms | 340 KB | Output is correct |
9 | Correct | 117 ms | 2288 KB | Output is correct |
10 | Correct | 772 ms | 17660 KB | Output is correct |
11 | Correct | 6 ms | 340 KB | Output is correct |
12 | Correct | 39 ms | 1176 KB | Output is correct |
13 | Execution timed out | 5021 ms | 8944 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 328 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Incorrect | 2 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 328 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Incorrect | 2 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 328 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Incorrect | 2 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 328 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Incorrect | 2 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 7 ms | 212 KB | Output is correct |
6 | Incorrect | 1 ms | 312 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 13 ms | 312 KB | Output is correct |
5 | Correct | 27 ms | 948 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Correct | 3 ms | 340 KB | Output is correct |
9 | Correct | 117 ms | 2288 KB | Output is correct |
10 | Correct | 772 ms | 17660 KB | Output is correct |
11 | Correct | 6 ms | 340 KB | Output is correct |
12 | Correct | 39 ms | 1176 KB | Output is correct |
13 | Execution timed out | 5021 ms | 8944 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |