# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202053 | SamAnd | Ronald (COCI17_ronald) | C++17 | 63 ms | 3320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |