#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const int N = 1e3 + 15;
int n, m, cur[N];
bool g[N][N], used[N];
bool dfs(int v, bool rev) {
used[v] = true;
cur[v] = rev;
if(rev)
for(int i = 1; i <= n; ++i) {
g[i][v] ^= 1;
g[v][i] ^= 1;
}
for(int i = 1; i <= n; ++i)
if(i != v && !g[i][v])
if(used[i] || !dfs(i, cur[i] ^ 1))
return false;
used[v] = false;
return true;
}
int main() {
cin >> n >> m;
for(int i = 1; i <= m; ++i) {
int u, v;
scanf("%d%d", &u, &v);
g[u][v] = g[v][u] = true;
}
for(int i = 1; i <= n; ++i) {
memset(used, 0, sizeof(used));
memset(cur, 0, sizeof(cur));
cur[i] = 0;
bool flag1 = dfs(i, 0);
memset(used, 0, sizeof(used));
memset(cur, 0, sizeof(cur));
cur[i] = 1;
bool flag2 = dfs(i, 1);
if(!flag1 && !flag2)
return cout << "NE", 0;
}
cout << "DA";
return 0;
}
Compilation message
ronald.cpp: In function 'int main()':
ronald.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &u, &v);
~~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
372 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
380 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
632 KB |
Output is correct |
2 |
Correct |
322 ms |
1352 KB |
Output is correct |
3 |
Correct |
65 ms |
760 KB |
Output is correct |
4 |
Correct |
5 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
504 KB |
Output is correct |
2 |
Correct |
13 ms |
1144 KB |
Output is correct |
3 |
Correct |
32 ms |
2552 KB |
Output is correct |
4 |
Execution timed out |
1072 ms |
3320 KB |
Time limit exceeded |