Submission #136961

# Submission time Handle Problem Language Result Execution time Memory
136961 2019-07-26T16:43:55 Z dnass Ronald (COCI17_ronald) C++14
120 / 120
76 ms 4472 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long int lld;

int n, m;
int adj[1010][1010];

void no(){
	printf("NE\n");
}

void yes(){
	printf("DA\n");
}

int main(){
	memset(adj, 0, sizeof adj);
	scanf("%d %d", &n, &m);
	if(m==(n*(n-1))/2){
		yes();
		return 0;
	}
	for(int i=0;i<m;i++){
		int a, b; scanf("%d %d", &a, &b);
		adj[a][b] = 1; adj[b][a] = 1;
	}
	vector<int> conns1, conns2;
	int node = -1;
	for(int i=1;i<=n;i++){
		if(adj[1][i]==0) node = i;
		else conns1.push_back(i);
	}
	if(node==-1){
		no();
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(adj[node][i]==1) conns2.push_back(i);
	}
	vector<int> intersection;
	set_intersection(conns1.begin(), conns1.end(), conns2.begin(), conns2.end(), back_inserter(intersection));
	if(!intersection.empty()){
		no();
		return 0;
	}
	conns1.push_back(1);
	sort(conns1.begin(), conns1.end());
	conns2.push_back(node);
	sort(conns2.begin(), conns2.end());
	if((int)conns1.size()+(int)conns2.size()!=n){
		no();
		return 0;
	}
	for(int n1:conns1){
		vector<int> connstest;
		for(int i=1;i<=n;i++){
			if(adj[n1][i]==1) connstest.push_back(i);
		}
		connstest.push_back(n1);
		sort(connstest.begin(), connstest.end());
		if(connstest==conns1){}
		else{
			no();
			return 0;
		}
	}
	for(int n2:conns2){
		vector<int> connstest;
		for(int i=1;i<=n;i++){
			if(adj[n2][i]==1) connstest.push_back(i);
		}
		connstest.push_back(n2);
		sort(connstest.begin(), connstest.end());
		if(connstest==conns2){}
		else{
			no();
			return 0;
		}
	}
	yes();
	return 0;
}

Compilation message

ronald.cpp: In function 'int main()':
ronald.cpp:19: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:25:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d %d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB Output is correct
2 Correct 5 ms 4344 KB Output is correct
3 Correct 5 ms 4344 KB Output is correct
4 Correct 5 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB Output is correct
2 Correct 5 ms 4344 KB Output is correct
3 Correct 6 ms 4344 KB Output is correct
4 Correct 5 ms 4324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB Output is correct
2 Correct 6 ms 4344 KB Output is correct
3 Correct 5 ms 4348 KB Output is correct
4 Correct 5 ms 4348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB Output is correct
2 Correct 5 ms 4344 KB Output is correct
3 Correct 5 ms 4344 KB Output is correct
4 Correct 5 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB Output is correct
2 Correct 5 ms 4344 KB Output is correct
3 Correct 6 ms 4344 KB Output is correct
4 Correct 6 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB Output is correct
2 Correct 6 ms 4344 KB Output is correct
3 Correct 6 ms 4344 KB Output is correct
4 Correct 6 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4344 KB Output is correct
2 Correct 22 ms 4472 KB Output is correct
3 Correct 12 ms 4348 KB Output is correct
4 Correct 8 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 4344 KB Output is correct
2 Correct 14 ms 4344 KB Output is correct
3 Correct 42 ms 4472 KB Output is correct
4 Correct 76 ms 4452 KB Output is correct