Submission #485293

#TimeUsernameProblemLanguageResultExecution timeMemory
485293SirCovidThe19thPotemkin cycle (CEOI15_indcyc)C++17
100 / 100
498 ms93000 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 1005, mxM = 2e5 + 5; int n, m, u[mxM], v[mxM], adj1[mxN][mxN]; vector<int> adj2[mxM], stk; bool vis[mxM], active[mxM]; void dfs(int cur, int p){ vis[cur] = active[cur] = 1; stk.push_back(cur); for (int nxt : adj2[cur]) if (nxt != p and active[nxt]){ while (stk.back() != nxt){ cout<<u[stk.back()]<<" "; stk.pop_back(); } cout<<u[stk.back()]<<endl; exit(0); } for (int nxt : adj2[cur]) if (nxt != p and !vis[nxt]) dfs(nxt, cur); active[cur] = 0; stk.pop_back(); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 1; i <= m; i++){ int a, b; cin >> a >> b; u[i * 2] = a; v[i * 2] = b; u[i * 2 + 1] = b; v[i * 2 + 1] = a; adj1[a][b] = i * 2; adj1[b][a] = i * 2 + 1; } for (int i = 1; i <= 2 * m; i++) for (int j = 1; j <= n; j++) if (adj1[v[i]][j] and j != u[i]) if (!adj1[u[i]][j]) adj2[i].push_back(adj1[v[i]][j]); for (int i = 1; i <= 2 * m; i++) if (!vis[i]) dfs(i, 0); cout<<"no"<<endl; }
#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...