# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
23495 | 2017-05-11T08:46:12 Z | ruhanhabib39 | Potemkin cycle (CEOI15_indcyc) | C++14 | 146 ms | 2164 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100; int N, M; set<int> G[MAXN + 10]; struct dat { deque<int> vec; bitset<MAXN+1> bad; void reset() { vec.clear(); bad.reset(); } int size() const { return vec.size(); } int at(int i) const { return vec[i]; } bool is_bad(int u) const { return bad.test(u); } int back() const { return vec.back(); } dat add_back(int u) { dat dt = *this; dt.vec.push_back(u); dt.bad.set(u); for(int v : G[back()]) { dt.bad.set(v); } return dt; } }; void work(int u, dat dt) { // if(dt.at(0) == 2) cerr << "u = " << u << "\n"; if(dt.size() >= 4) { if(G[u].find(dt.at(0)) != G[u].end()) { for(int x : dt.vec) { printf("%d ", x); } printf("\n"); exit(0); } } if(dt.size() > 2 && G[u].find(dt.at(0)) != G[u].end()) return; for(int v : G[u]) { // if(dt.at(0) == 2) cerr << v << " is bad\n"; if(!dt.is_bad(v)) { // if(dt.at(0) == 2) cerr << ">>>>>>>>>>>>>>>>>>>>>>>>\n"; work(v, dt.add_back(v)); // if(dt.at(0) == 2) cerr << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"; } } } int main() { scanf("%d%d", &N, &M); for(int i = 0; i < M; i++) { int u, v; scanf("%d%d", &u, &v); G[u].insert(v); G[v].insert(u); } for(int u = 1; u <= N; u++) { for(int v : G[u]) { dat dt; dt.vec.push_back(u); dt.bad.set(u); dt.vec.push_back(v); dt.bad.set(v); // cerr << u << "-> " << v << "\n"; work(v, dt); } } printf("no\n"); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2032 KB | Output is correct |
2 | Correct | 0 ms | 2032 KB | Output is correct |
3 | Correct | 0 ms | 2032 KB | Output is correct |
4 | Correct | 0 ms | 2032 KB | Output is correct |
5 | Correct | 0 ms | 2032 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2032 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2032 KB | Output is correct |
2 | Correct | 0 ms | 2032 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2032 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2164 KB | Output is correct |
2 | Correct | 146 ms | 2164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 2032 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 2032 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 2032 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 2032 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 2032 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |