# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244491 | tqbfjotld | Potemkin cycle (CEOI15_indcyc) | C++14 | 1095 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n,e;
bool adjm[15][15];
vector<int> cur;
bool used[15];
bool thing(){
for (int x = 0; x<n; x++){
if (used[x]) continue;
if (cur.size()>0&&!adjm[x][cur[cur.size()-1]])continue;
bool possible = true;
for (int y = 1; 1+y<cur.size(); y++){
if (adjm[x][cur[y]]){
possible = false;
}
}
if (possible){
if (cur.size()>=3&&adjm[x][cur[0]]){
cur.push_back(x);
return true;
}
if (cur.size()>1&&adjm[x][cur[0]]) continue;
cur.push_back(x);
used[x] = true;
if (thing()){
return true;
}
cur.pop_back();
used[x] = false;
}
}
return false;
}
int main(){
scanf("%d%d",&n,&e);
for (int x = 0; x<e; x++){
int a,b;
scanf("%d%d",&a,&b);
a--;b--;
adjm[a][b] = 1;
adjm[b][a] = 1;
}
if (thing()){
for (int x : cur){
printf("%d ",1+x);
}
}
else{
printf("no");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |