Submission #370991

# Submission time Handle Problem Language Result Execution time Memory
370991 2021-02-25T11:18:32 Z FatihSolak Ronald (COCI17_ronald) C++17
120 / 120
136 ms 3360 KB
#include <bits/stdc++.h>
#define N 1005
using namespace std;
bool adj[N][N];
int n,m;
bool calc(){
	vector<int> ch;
	for(int i=2;i<=n;i++){
		if(!adj[1][i]){
			ch.push_back(i);
		}
	}
	for(auto u:ch){
		for(int i=1;i<=n;i++){
			if(u != i)
				adj[u][i] = adj[i][u] = !adj[u][i];
		}
	}
	int cnt = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cnt += adj[i][j];
		}
	}
	return cnt == (n*(n-1));
}
int main(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		adj[a][b] = 1;
		adj[b][a] = 1;
	}
	bool ok = calc();
	for(int i=2;i<=n;i++){
		adj[1][i] = adj[i][1] = !adj[1][i];
	}
	ok |= calc();
	cout << (ok?"DA":"NE") << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 620 KB Output is correct
2 Correct 35 ms 1260 KB Output is correct
3 Correct 12 ms 748 KB Output is correct
4 Correct 8 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 620 KB Output is correct
2 Correct 22 ms 1132 KB Output is correct
3 Correct 84 ms 2540 KB Output is correct
4 Correct 136 ms 3360 KB Output is correct