# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
598882 | 2022-07-19T07:07:04 Z | 장태환(#8458) | Potemkin cycle (CEOI15_indcyc) | C++17 | 16 ms | 2668 KB |
#include <bits/stdc++.h> #include <assert.h> using namespace std; int num[1010]; int depth[1010]; vector<pair<int,int>> maxbe[1010]; int par[1010]; vector<int>link[1010]; bool arr[1010][1010]; vector<pair<int, int>>t; vector<int>ue[1010], de[1010]; int c; void dfs(int n, int p = 0, int d = 0) { depth[n] = d; num[n] = ++c; par[n] = p; int i; for (i = 0; i < link[n].size(); i++) { if (link[n][i] == p) continue; if (num[link[n][i]]) { if (depth[link[n][i]] < d) { if (arr[n][link[n][i]]) continue; arr[n][link[n][i]] = 1; maxbe[n].push_back({ depth[link[n][i]],link[n][i] }); t.push_back({ n,link[n][i] }); } else { if (arr[link[n][i]][n]) continue; arr[link[n][i]][n] = 1; maxbe[link[n][i]].push_back({d,n }); t.push_back({ link[n][i],n }); } } else { dfs(link[n][i], n, d + 1); } } } int main() { memset(maxbe, -10, sizeof(maxbe)); ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M; cin >> N >> M; int i; for (i = 0; i < M; i++) { int a, b; cin >> a >> b; link[a].push_back(b); link[b].push_back(a); } for (i = 1; i <= N; i++) { if (!num[i]) { dfs(i); } } for (i = 1; i <= N; i++) { sort(maxbe[i].begin(), maxbe[i].end()); } for (i = 0; i < t.size(); i++) { vector<int>ans; int c = -1; while (depth[t[i].first] > depth[t[i].second]) { c++; ans.push_back(t[i].first); pair<int, int>xe; xe.first = depth[t[i].second]+(c==0); xe.second = 0; auto ne = lower_bound(maxbe[t[i].first].begin(), maxbe[t[i].second].end(),xe ); if (ne!=maxbe[t[i].second].end()) { t[i].first =ne->second; } else t[i].first = par[t[i].first]; } ans.push_back(t[i].second); if (ans.size() <= 3) { continue; } for (i = 0; i < ans.size(); i++) cout << ans[i] << ' '; return 0; } cout << "no"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 648 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 724 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 724 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 8 ms | 1748 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 1236 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 16 ms | 2668 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |