Submission #227679

# Submission time Handle Problem Language Result Execution time Memory
227679 2020-04-28T12:15:12 Z cstuart Ronald (COCI17_ronald) C++17
120 / 120
46 ms 3192 KB
#define USE_MATH_DEFINES 1
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 998244353ll
#define INF 1000000000000000000ll
#define EPS 1e-9

#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll N, M;
bool adj[1005][1005], state[1005], yes;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N >> M;
	for (ll i = 1; i <= M; i++) {
		ll x, y;
		cin >> x >> y;
		adj[x][y] = true;
		adj[y][x] = true;
	}
	
	state[1] = 1;
	for (ll j = 2; j <= N; j++) {
		state[j] = adj[1][j];
	}
	
	yes = true;
	for (ll i = 2; i <= N; i++) {
		for (ll j = 1; j <= N; j++) {
			if (i == j) continue;
			if  (adj[i][j] && (state[i] != state[j])) yes = false;
			if (!adj[i][j] && (state[i] == state[j])) yes = false;
		}
	}
	
	cout << ((yes) ? "DA" : "NE");
	
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 544 KB Output is correct
2 Correct 15 ms 1356 KB Output is correct
3 Correct 8 ms 768 KB Output is correct
4 Correct 8 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 640 KB Output is correct
2 Correct 12 ms 1152 KB Output is correct
3 Correct 33 ms 2560 KB Output is correct
4 Correct 46 ms 3192 KB Output is correct