# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40448 | 2018-02-01T14:33:39 Z | Pajaraja | Potemkin cycle (CEOI15_indcyc) | C++14 | 29 ms | 2156 KB |
#include <bits/stdc++.h> using namespace std; vector<int> g[1007],d,k; bool m[1007][1007],vi[1007],uc[1007]; int p[1007]; void dfs(int s,int og) { if(m[s][og]) { k.push_back(s); vi[s]=true; d.push_back(s); return; } vi[s]=true; for(int i=0;i<g[s].size();i++) if(!vi[g[s][i]]) dfs(g[s][i],og); } void bfs(int s,int r,int l) { fill(p,p+1007,-1); queue<int> q; p[s]=0; p[l]=s; q.push(l); while(!q.empty()) { int u=q.front(); q.pop(); for(int i=0;i<g[u].size();i++) if(p[g[u][i]]==-1) { p[g[u][i]]=u; q.push(g[u][i]); } } int x=r; while(x>0) { printf("%d ",x); x=p[x]; } } int main() { int n,ma; scanf("%d%d",&n,&ma); for(int i=0;i<ma;i++) { int t1,t2; scanf("%d%d",&t1,&t2); g[t1].push_back(t2); g[t2].push_back(t1); m[t1][t2]=m[t2][t1]=true; } for(int i=1;i<=n;i++) m[i][i]=true; for(int i=1;i<=n;i++) { int cnt=0; fill(vi,vi+1+n,false); for(int j=1;j<=n;j++) if(!vi[j] && !m[i][j] && i!=j) { k.clear(); dfs(j,i); for(int z=0;z<d.size();z++) vi[z]=false; d.clear(); cnt++; for(int z=0;z<k.size();z++) for(int t=z+1;t<k.size();t++) if(!m[k[z]][k[t]]) { bfs(i,k[z],k[t]); return 0; } } } printf("no"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 480 KB | Output is correct |
3 | Correct | 2 ms | 480 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 684 KB | Wrong adjacency |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 684 KB | Output is correct |
2 | Correct | 2 ms | 684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 748 KB | Wrong adjacency |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1004 KB | Output is correct |
2 | Incorrect | 3 ms | 1004 KB | Wrong adjacency |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1004 KB | Wrong adjacency |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 2156 KB | Wrong adjacency |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 29 ms | 2156 KB | Wrong adjacency |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 2156 KB | Wrong adjacency |
2 | Halted | 0 ms | 0 KB | - |