답안 #202053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
202053 2020-02-13T10:00:37 Z SamAnd Ronald (COCI17_ronald) C++17
120 / 120
63 ms 3320 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1003;

int n, m;

bool a[N][N];

int c[N];

bool dfs(int x, int u)
{
    c[x] = u;
    for (int h = 1; h <= n; ++h)
    {
        if (h == x)
            continue;
        if (!c[h])
        {
            if (a[x][h] == false)
            {
                if (!dfs(h, 3 - u))
                    return false;
            }
            else
            {
                if (!dfs(h, u))
                    return false;
            }
        }
        else
        {
            if (a[x][h] == false)
            {
                if (c[h] != 3 - u)
                    return false;
            }
            else
            {
                if (c[h] != u)
                    return false;
            }
        }
    }
    return true;
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        a[x][y] = true;
        a[y][x] = true;
    }
    if (dfs(1, 1))
    {
        printf("DA\n");
        return 0;
    }
    printf("NE\n");
    return 0;
}

Compilation message

ronald.cpp: In function 'int main()':
ronald.cpp:50:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
ronald.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 368 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 632 KB Output is correct
2 Correct 19 ms 1400 KB Output is correct
3 Correct 10 ms 760 KB Output is correct
4 Correct 9 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 14 ms 1144 KB Output is correct
3 Correct 40 ms 2552 KB Output is correct
4 Correct 63 ms 3320 KB Output is correct