# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
598823 | 2022-07-19T06:09:47 Z | 조영욱(#8459) | Potemkin cycle (CEOI15_indcyc) | C++17 | 742 ms | 340 KB |
#include <bits/stdc++.h> using namespace std; int n,m; bool arr[10][10]; int p[10]; int deg[10]; int find(int a) { return p[a]<0?a:p[a]=find(p[a]); } void merge(int a,int b) { a=find(a); b=find(b); if (a!=b) { p[a]+=p[b]; p[b]=a; } } int main() { scanf("%d %d",&n,&m); for(int i=0;i<m;i++) { int u,v; scanf("%d %d",&u,&v); u--; v--; arr[u][v]=true; arr[v][u]=true; } for(int bit=0;bit<(1<<n);bit++) { int sz=0; for(int i=0;i<n;i++) { if (bit&(1<<i)) { sz++; } } if (sz<4) { continue; } int cnt=0; memset(p,-1,sizeof(p)); memset(deg,0,sizeof(deg)); int f=-1; for(int i=0;i<n;i++) { if (bit&(1<<i)) { if (f==-1) { f=i; } for(int j=i+1;j<n;j++) { if (bit&(1<<j)) { if (arr[i][j]) { cnt++; merge(i,j); deg[i]++; deg[j]++; } } } } } if (-p[find(f)]!=sz||sz!=cnt) { continue; } bool flag=true; for(int i=0;i<n;i++) { if ((bit&(1<<i))&°[i]!=2) { flag=false; break; } } if (flag) { int now=f; int pr=-1; vector<int> v; //printf("%d\n",bit); int save=0; while (1) { //save++; //if (save>=1000) exit(0); v.push_back(now); int nt=-1; for(int i=0;i<n;i++) { if (bit&(1<<i)) { if (i!=pr&&arr[now][i]) { nt=i; break; } } } if (nt==f) { break; } pr=now; now=nt; } for(int i=0;i<v.size();i++) { printf("%d ",v[i]+1); } return 0; } } printf("no"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 35 ms | 284 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 695 ms | 276 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 728 ms | 272 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 296 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 742 ms | 272 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |