Submission #896461

# Submission time Handle Problem Language Result Execution time Memory
896461 2024-01-01T13:39:36 Z AndrijaM Potemkin cycle (CEOI15_indcyc) C++14
10 / 100
31 ms 2120 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int>g[n];
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bool vis[n];
    bool sosed[n];
    for(int i=0;i<n;i++)
    {
        if(g[i].size()<=1)
        {
            continue;
        }
        memset(vis,0,sizeof vis);
        memset(sosed,0,sizeof sosed);
        vis[i]=true;
        vector<int>ans;
        vector<int>p;
        for(auto ax:g[i])
        {
            sosed[ax]=true;
            p.push_back(ax);
        }
        int par[n];
        for(auto ax:p)
        {
            memset(par,-1,sizeof par);
            par[ax]=i;
            memset(vis,0,sizeof vis);
            vis[i]=true;
            queue<int>Q;
            Q.push(ax);
            Q.push(2);
            vis[ax]=true;
            while(!Q.empty())
            {
                int teme=Q.front();Q.pop();
                int k=Q.front();Q.pop();
                if(sosed[teme]==true)
                {
                    if(k>=4)
                    {
                        int t=teme;
                        while(par[t]!=-1)
                        {
                            cout<<t+1<<" ";
                            t=par[t];
                        }
                        cout<<i+1<<endl;
                        return 0;
                    }
                }
                for(auto a:g[teme])
                {
                    if(vis[a]==true)
                    {
                        break;

                    }
                    par[a]=teme;
                    Q.push(a);
                    Q.push(k+1);
                    vis[a]=true;
                }
            }
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Unexpected end of file - token expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Wrong answer on graph without induced cycle
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1136 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 856 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 2120 KB Wrong adjacency
2 Halted 0 ms 0 KB -