Submission #37655

#TimeUsernameProblemLanguageResultExecution timeMemory
37655nickyrioPotemkin cycle (CEOI15_indcyc)C++14
10 / 100
1000 ms3444 KiB
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = a; i<= b; ++i) #define FORD(i, a, b) for (int i = a; i>=b; --i) #define REP(i, a) for (int i = 0; i<a; ++i) #define DEBUG(x) { cerr << #x << " = " << x << endl; } #define Arr(A, l, r) { cerr << #A << " = "; FOR(_, l, r) cerr << A[_] << ' '; cerr << endl; } #define N 1111 #define pp pair<int, int> #define next __next #define prev __prev #define __builtin_popcount __builtin_popcountll #define bit(S, i) (((S) >> i) & 1) #define IO cin.tie(NULL);cout.tie(NULL); #define taskname "Test" using namespace std; int n, m, p[N]; vector<int> e[N]; queue<int> q; bitset<N> banned[N], parent[N]; void Try(int s) { while (!q.empty()) q.pop(); FOR(i, 1, n) { p[i] = 0; banned[i].reset(); parent[i].reset(); } q.push(s); parent[s].set(s); p[s] = -1; while (!q.empty()) { int u = q.front();q.pop(); for (int v : e[u]) if (v != p[u]) { if (p[v] == 0) { } else { // FOR(i, 1, n) if (banned[v][i]) cerr << i << ' '; cerr << endl; // FOR(i, 1, n) if (parent[u][i]) cerr << i << ' '; cerr << endl; if (parent[u].count() + parent[v].count() > 4 && (banned[v] & parent[u]).count() == 0) { vector<int> res; int t = u; while (t != s) { res.push_back(t); t = p[t]; } for (int x : res) cout << x << ' '; t = v; while (t != -1) { cout << t << ' '; t = p[t]; } exit(0); } banned[u].set(v); banned[v].set(u); } } for (int v : e[u]) if (v != p[u]) { if (p[v] == 0) { p[v] = u; banned[v] = banned[u]; parent[v] = parent[u]; parent[v].set(v); q.push(v); } } } } int main() { // freopen(taskname".inp","r",stdin); // freopen(taskname".out","w",stdout); IO;ios::sync_with_stdio(false); cin >> n >> m; REP(i, m) { int u, v; cin >> u >> v; e[u].push_back(v); e[v].push_back(u); } FOR(i, 1, n) Try(i); cout << "no"; }
#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...