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;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
const int N = 1005;
int w[N][N], col[N];
bool ans = true;
bool used[N];
int n, m;
void dfs(int node) {
used[node] = 1;
for (int i = 0; i < n; i++) {
if (i != node) {
if (!used[i]) {
col[i] = col[node] ^ w[node][i];
dfs(i);
}
else if (col[i] != (col[node] ^ w[node][i])) {
ans = false;
}
}
}
}
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
w[i][j] = 1;
}
}
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
a--, b--;
w[a][b] = 0;
w[b][a] = 0;
}
dfs(0);
cout << (ans ? "DA" : "NE");
return 0;
}
# | 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... |