Submission #531038

#TimeUsernameProblemLanguageResultExecution timeMemory
531038Yazan_AlattarPotemkin cycle (CEOI15_indcyc)C++14
100 / 100
481 ms93088 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define F first #define S second #define pb push_back #define endl "\n" #define all(x) x.begin(), x.end() const int M = 1007; const int N = 200007; const ll inf = 2e9; const ll mod = 1e6 + 7; const double pi = acos(-1); const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0}; const int block = 320; stack <int> st; vector <int> adj[N]; int n, m, v[N], u[N], lis[M][M]; bool vist[N], onstack[N]; void dfs(int node, int p){ vist[node] = onstack[node] = 1; st.push(node); for(auto i : adj[node]) if(i != p && onstack[i]){ while(st.top() != i) printf("%d ", v[st.top()]), st.pop(); printf("%d ", v[i]); exit(0); } for(auto i : adj[node]) if(i != p && !vist[i]) dfs(i, node); onstack[node] = 0; st.pop(); return; } int main(){ scanf("%d%d", &n, &m); for(int i = 1; i <= m; ++i){ int a, b; scanf("%d%d", &a, &b); v[2 * i] = a; u[2 * i] = b; v[2 * i + 1] = b; u[2 * i + 1] = a; lis[a][b] = 2 * i; lis[b][a] = 2 * i + 1; } for(int i = 1; i <= 2 * m; ++i) for(int j = 1; j <= n; ++j) if(lis[u[i]][j] && j != v[i] && !lis[v[i]][j]) adj[i].pb(lis[u[i]][j]); for(int i = 1; i <= 2 * m; ++i) if(!vist[i]) dfs(i, 0); cout << "no\n"; return 0; }

Compilation message (stderr)

indcyc.cpp: In function 'int main()':
indcyc.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
indcyc.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
#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...