답안 #54399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54399 2018-07-03T10:09:36 Z Costin Andrei Oncescu(#1303) Potemkin cycle (CEOI15_indcyc) C++11
70 / 100
1000 ms 6800 KB
#include<bits/stdc++.h>

using namespace std;

int N, M, d[1009], canTake[1009], how[1009], x[100009], y[100009];
bool ap[1009][1009];
vector < int > v[1009];
queue < int > cc;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
for (int i=1; i<=M; i++)
{
    scanf ("%d %d", &x[i], &y[i]);
    v[x[i]].push_back (y[i]);
    v[y[i]].push_back (x[i]);
    ap[x[i]][y[i]] = ap[y[i]][x[i]] = 1;
}
for (int e=1; e<=M; e++)
{
    int a = x[e], b = y[e];
    for (int i=1; i<=N; i++)
        canTake[i] = (i == a || i == b || (ap[i][a] & ap[i][b]) == 0),
        d[i] = -1, how[i] = 0;
    cc.push (a), d[a] = 0, how[a] = 0;
    while (!cc.empty ())
    {
        int nod = cc.front ();
        cc.pop ();
        for (auto it : v[nod])
            if (canTake[it] == 1 && d[it] == -1 && (nod != a || it != b))
                d[it] = d[nod] + 1, how[it] = nod, cc.push (it);
    }
    if (d[b] != -1)
    {
        while (b != 0)
            printf ("%d ", b),
            b = how[b];
        printf ("\n");
        return 0;
    }
}
printf ("no\n");
return 0;
}

Compilation message

indcyc.cpp: In function 'int main()':
indcyc.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d %d", &N, &M);
 ~~~~~~^~~~~~~~~~~~~~~~~
indcyc.cpp:18:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &x[i], &y[i]);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 572 KB Output is correct
2 Correct 2 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 772 KB Output is correct
2 Correct 10 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1104 KB Output is correct
2 Correct 3 ms 1104 KB Output is correct
3 Correct 4 ms 1232 KB Output is correct
4 Correct 82 ms 1412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1412 KB Output is correct
2 Correct 80 ms 1416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 3304 KB Output is correct
2 Correct 56 ms 3304 KB Output is correct
3 Execution timed out 1061 ms 3736 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 333 ms 3736 KB Output is correct
2 Execution timed out 1074 ms 3736 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 5016 KB Output is correct
2 Correct 222 ms 5852 KB Output is correct
3 Correct 105 ms 6308 KB Output is correct
4 Execution timed out 1075 ms 6800 KB Time limit exceeded