Submission #368369

# Submission time Handle Problem Language Result Execution time Memory
368369 2021-02-20T01:39:54 Z TosakaUCW Ronald (COCI17_ronald) C++17
120 / 120
17 ms 7916 KB
#include <stdio.h>
#include <algorithm>
#include <memory.h>
#include <vector>
#include <stdlib.h>

int read(int x = 0, int f = 0, char ch = getchar())
{
    while ('0' > ch or ch > '9')
        f = ch == '-', ch = getchar();
    while ('0' <= ch and ch <= '9')
        x = x * 10 + (ch ^ 48), ch = getchar();
    return f ? -x : x;
}

const int N = 1e5 + 5;

int n, m, cnt;
bool vis[N];
std::vector<int> G[N];

void dfs(int u, int last = -1)
{
    if (last != -1 and G[u].size() != last)
        puts("NE"), exit(0);
    vis[u] = true;
    for (auto v : G[u])
        if (!vis[v])
            dfs(v, G[u].size());
}

int main()
{
    // freopen("ronald.in", "r", stdin), freopen("ronald.out", "w", stdout);
    n = read(), m = read();
    for (int u, v; m--;)
        u = read(), v = read(),
        G[u].push_back(v), G[v].push_back(u);
    for (int i = 1; i <= n; i++)
        if (!vis[i])
            dfs(i), cnt++;
    return puts(cnt > 2 ? "NE" : "DA"), 0;
}

Compilation message

ronald.cpp: In function 'void dfs(int, int)':
ronald.cpp:24:36: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     if (last != -1 and G[u].size() != last)
      |                        ~~~~~~~~~~~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2716 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2796 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2796 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2924 KB Output is correct
2 Correct 6 ms 3948 KB Output is correct
3 Correct 3 ms 3052 KB Output is correct
4 Correct 3 ms 2924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2796 KB Output is correct
2 Correct 5 ms 3692 KB Output is correct
3 Correct 14 ms 6252 KB Output is correct
4 Correct 17 ms 7916 KB Output is correct