# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
34350 | bnahmad15 | Potemkin cycle (CEOI15_indcyc) | C++14 | 1000 ms | 3940 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,m,u,v;
bool cant[1001]={false},is[1001][1001]={false};
vector<int> adj[1001];
vector <int> taken;
bool check(){
for (int i =1 ;i<taken.size();i++){
if (!is[taken[i]][taken[i-1]])
return false;
}
if (!is[taken[0]][taken.back()])
return false;
for (int i = 0 ;i<taken.size();i++){
for (int j = i+2;j<taken.size();j++){
if (i==0 && j==taken.size()-1)
continue;
if (is[taken[i]][taken[j]])
return false;
}
}
return true;
}
void output(vector <int> &to){
for(auto i : to)
printf("%d ",i+1);
exit(0);
}
void rec(int id){
if (id >= 4 &&check())
output(taken);
if (id == n)
return;
for(int i = 0;i<n;i++){
if (cant[i])
continue;
cant[i]=true;
taken.push_back(i);
rec(id+1);
cant[i]=false;
taken.pop_back();
}
}
int main(){
scanf ("%d%d",&n,&m);
for (int i = 0; i <m ;i++){
scanf("%d%d",&u,&v);
u--;
v--;
adj[u].push_back(v);
adj[v].push_back(u);
is[u][v]=is[v][u]=true;
}
rec(0);
puts("no");
return 0;
}
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... |