# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
172951 | phillip | Potemkin cycle (CEOI15_indcyc) | C++14 | 123 ms | 504 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>
#define ll long long
using namespace std;
int vis[109],org;
vector<int>cc,v[109];
void out()
{
for(int i=0;i<cc.size();i++)cout<<cc[i]+1<<" ";
exit(0);
}
void dfs(int x,int par)
{
//cout<<x<<" "<<par<<"\n";
cc.push_back(x);
for(int i=0;i<v[x].size();i++)
{
if(v[x][i]==par)continue;
if(vis[v[x][i]])
{
if(v[x][i]==org&&cc.size()>=4)continue;
cc.pop_back();
return;
}
}
for(int i=0;i<v[x].size();i++)
{
if(v[x][i]==par)continue;
if(v[x][i]==org&&cc.size()>=4)out();
}
vis[x]=1;
for(int i=0;i<v[x].size();i++)
{
int y=v[x][i];
if(y==par)continue;
dfs(y,x);
}
cc.pop_back();
vis[x]=0;
}
int n,m,x,y;
int main()
{
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>x>>y;
x--;y--;
v[x].push_back(y);
v[y].push_back(x);
}
for(int i=0;i<n;i++)
{
memset(vis,0,sizeof(vis));
org=i;
dfs(i,i);
}
cout<<"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... |