Submission #126669

# Submission time Handle Problem Language Result Execution time Memory
126669 2019-07-08T09:01:16 Z abacaba Ronald (COCI17_ronald) C++14
0 / 120
2 ms 376 KB
#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;
	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, 1))
				return false;
	used[v] = false;
	return true;
}

int main() {
	freopen("input.txt", "r", stdin);
	scanf("%d%d", &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));
		cur[i] = 0;
		bool flag1 = dfs(i, 0);
		memset(used, 0, sizeof(used));
		cur[i] = 1;
		bool flag2 = dfs(i, 1);
		if(!flag1 && !flag2) {
			puts("NE");
			return 0;
		}
	}
	puts("DA");
    return 0;
}

Compilation message

ronald.cpp: In function 'int main()':
ronald.cpp:25:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("input.txt", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ronald.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
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);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -