# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
172833 | phillip | Potemkin cycle (CEOI15_indcyc) | C++14 | 4 ms | 540 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];
int n,m,ed[109][109];
vector<int>v[109],c;
void ot()
{
for(int i=0;i<c.size();i++)cout<<c[i]+1<<" ";
exit(0);
}
void dfs(int x,int par)
{
c.push_back(x);
//for(int i=0;i<c.size();i++)cout<<c[i]<<" ";cout<<"\n";
vis[x]=1;
for(int i=0;i<v[x].size();i++)
{
int y=v[x][i];
if(y==par||vis[y])continue;
bool o=1;
for(int j=1;j<c.size()-1;j++)
{
if(ed[y][c[j]]){o=0;break;}
}
if(o&&c.size()+1>=4&&ed[c[0]][y])
{
c.push_back(y);
ot();
}
else if(o&&(ed[c[0]][y]==0||x==c[0]))dfs(y,x);
}
c.pop_back();
}
int main()
{
cin>>n>>m;
int x,y;
for(int i=0;i<m;i++)
{
cin>>x>>y;
x--;y--;
ed[x][y]=1;
ed[y][x]=1;
v[x].push_back(y);
v[y].push_back(x);
}
for(int i=0;i<n;i++)
{
memset(vis,0,sizeof(vis));
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... |