답안 #136942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136942 2019-07-26T15:47:05 Z dnass Ronald (COCI17_ronald) C++14
105 / 120
75 ms 4344 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());
	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);
             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 4344 KB Output is correct
# 결과 실행 시간 메모리 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 4344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4344 KB Output is correct
2 Correct 2 ms 4344 KB Output is correct
3 Correct 5 ms 4344 KB Output is correct
4 Correct 5 ms 4344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4344 KB Output is correct
2 Incorrect 5 ms 4344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 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
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4344 KB Output is correct
2 Correct 22 ms 4344 KB Output is correct
3 Correct 12 ms 4344 KB Output is correct
4 Correct 8 ms 4344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4344 KB Output is correct
2 Correct 14 ms 4344 KB Output is correct
3 Correct 39 ms 4344 KB Output is correct
4 Correct 75 ms 4344 KB Output is correct