Submission #95850

# Submission time Handle Problem Language Result Execution time Memory
95850 2019-02-03T07:14:36 Z Kastanda Potemkin cycle (CEOI15_indcyc) C++11
40 / 100
204 ms 2044 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 1009;
int n, m, qu[N], P[N];
bitset < N > M, S, is[N];
vector < int > Adj[N];
inline void Prnt(int fxd, int v, int u)
{
    M = S = 0;
    for (int &w : Adj[fxd])
        M[w] = 1;
    int l = 0, r = 0;
    qu[r ++] = v;
    S[v] = 1;
    while (r - l)
    {
        int nw = qu[l ++];
        for (int &w : Adj[nw])
            if (w != fxd && !S[w])
            {
                S[w] = 1;
                P[w] = nw;
                if (!M[w])
                    qu[r ++] = w;
            }
    }
    printf("%d", fxd);
    for (; u; u = P[u])
        printf(" %d", u);
    printf("\n");
    exit(0);
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++)
    {
        int v, u;
        scanf("%d%d", &v, &u);
        Adj[v].push_back(u);
        Adj[u].push_back(v);
        is[v][u] = is[u][v] = 1;
    }
    for (int fxd = 1; fxd <= n; fxd ++)
    {
        M = S = 0;
        for (int &v : Adj[fxd])
            M[v] = 1;
        for (int &v : Adj[fxd])
        {
            int l = 0, r = 0;
            qu[r ++] = v;
            vector < int > A = {v};
            S[v] = 1;
            while (r - l)
            {
                int u = qu[l ++];
                for (int &w : Adj[u])
                    if (w != fxd && !S[w] && !(M[u] && M[w]))
                    {
                        S[w] = 1;
                        if (M[w])
                            A.push_back(w);
                        else
                            qu[r ++] = w;
                    }
            }
            for (int i = 0; i < (int)A.size(); i++)
                for (int j = i + 1; j < (int)A.size(); j++)
                    if (!is[A[i]][A[j]])
                        Prnt(fxd, A[i], A[j]);
        }
    }
    return !printf("no\n");
}

Compilation message

indcyc.cpp: In function 'int main()':
indcyc.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
indcyc.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &v, &u);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 292 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer on graph without induced cycle
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 380 KB Wrong answer on graph without induced cycle
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Too short sequence
4 Incorrect 3 ms 504 KB Wrong answer on graph without induced cycle
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Too short sequence
2 Incorrect 3 ms 372 KB Wrong answer on graph without induced cycle
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1400 KB Output is correct
2 Correct 10 ms 892 KB Output is correct
3 Correct 192 ms 1400 KB Output is correct
4 Correct 96 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 888 KB Too short sequence
2 Incorrect 7 ms 888 KB Wrong answer on graph without induced cycle
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2032 KB Output is correct
2 Correct 204 ms 2044 KB Output is correct
3 Correct 15 ms 1660 KB Too short sequence
4 Incorrect 15 ms 1656 KB Wrong answer on graph without induced cycle