# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
54781 | 2018-07-05T05:14:36 Z | 2등은 나의 것^^(#2060) | Potemkin cycle (CEOI15_indcyc) | C++11 | 26 ms | 2644 KB |
#include<stdio.h> #include<algorithm> #include<vector> using namespace std; vector<int>edge[1212]; bool is_gone_dfs1[1212]; int depth[1212], MX[1212], ck[1212]; void dfs1(int w,int dep,int bef) { depth[w] = dep; is_gone_dfs1[w] = 1; for (int i = 0; i < edge[w].size(); i++) { int next = edge[w][i]; if (is_gone_dfs1[next]) { if(next==bef || depth[next] > depth[w])continue; if (MX[w] < depth[next])MX[w] = depth[next]; continue; } dfs1(next, dep + 1, w); } } int stdep; int dfs2(int w) { if (ck[w]) { printf("%d ", w); return 1; } for (int i = 0; i < edge[w].size(); i++) { int next = edge[w][i]; if (depth[next] - depth[w] != 1)continue; if (MX[next] && (!ck[next] && MX[next] == stdep))continue; if (MX[next] && MX[next] > stdep)continue; if (dfs2(next)) { printf("%d ", w); return 1; } } return 0; } int main() { int n, m; scanf("%d%d", &n, &m); int i, j; for (i = 0; i < m; i++) { int s, e; scanf("%d%d", &s, &e); edge[s].push_back(e); edge[e].push_back(s); } for (i = 1; i <= n; i++) { if (is_gone_dfs1[i])continue; dfs1(i, 1, -1); } for (i = 1; i <= n; i++) { for (j = 0; j < edge[i].size(); j++) ck[edge[i][j]] = (depth[edge[i][j]] - depth[i] >= 3); stdep = depth[i]; if (dfs2(i)) return 0; for (j = 0; j < edge[i].size(); j++) ck[edge[i][j]] = 0; } printf("no"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Correct | 2 ms | 620 KB | Output is correct |
4 | Correct | 2 ms | 620 KB | Output is correct |
5 | Correct | 2 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 620 KB | Expected integer, but "no" found |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 620 KB | Expected integer, but "no" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 620 KB | Expected integer, but "no" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 620 KB | Output is correct |
2 | Incorrect | 3 ms | 724 KB | Expected integer, but "no" found |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 724 KB | Expected integer, but "no" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 1144 KB | Expected integer, but "no" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1144 KB | Expected integer, but "no" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 1632 KB | Output is correct |
2 | Correct | 26 ms | 2300 KB | Output is correct |
3 | Incorrect | 23 ms | 2644 KB | Expected integer, but "no" found |
4 | Halted | 0 ms | 0 KB | - |