Submission #680090

#TimeUsernameProblemLanguageResultExecution timeMemory
680090GusterGoose27Potemkin cycle (CEOI15_indcyc)C++11
40 / 100
178 ms2052 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int MAXN = 1000; int n, m; vector<int> edges[MAXN]; int adj[MAXN]; bool vis[MAXN]; bool make_ans(int s, int cur, int msk = 0, int num = 1) { msk |= (1 << cur); for (int nxt: edges[cur]) { if ((1 << nxt) & msk) continue; if ((adj[nxt] & msk) == (1 << cur)) { if (make_ans(s, nxt, msk, num+1)) { cout << (1+cur); if (cur != s) cout << ' '; return 1; } } else if ((adj[nxt] & msk) == ((1 << cur) | (1 << s))) { if (num >= 3) { cout << (1+nxt) << ' ' << (1+cur) << ' '; return 1; } } } return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; x--; y--; edges[x].push_back(y); edges[y].push_back(x); adj[x] |= (1 << y); adj[y] |= (1 << x); } for (int i = 0; i < n; i++) { if (make_ans(i, i)) return 0; } cout << "no\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...