답안 #488534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
488534 2021-11-19T13:38:31 Z rainboy Logičari (COCI21_logicari) C
20 / 110
26 ms 284 KB
#include <stdio.h>

#define N	20

int min(int a, int b) { return a < b ? a : b; }

int main() {
	static int bb[N];
	int n, h, i, j, b, k_;

	scanf("%d", &n);
	if (n > N) {
		printf("%d\n", n % 4 == 0 ? n / 2 : -1);
		return 0;
	}
	for (h = 0; h < n; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		bb[i] |= 1 << j, bb[j] |= 1 << i;
	}
	k_ = n + 1;
	for (b = 0; b < 1 << n; b++) {
		int b_ = 0, k = 0;

		for (i = 0; i < n; i++)
			if ((b & 1 << i) != 0) {
				if ((b_ & bb[i]) != 0) {
					b_ = -1;
					break;
				}
				b_ |= bb[i], k++;
			}
		if (b_ == (1 << n) - 1)
			k_ = min(k_, k);
	}
	if (k_ == n + 1)
		k_ = -1;
	printf("%d\n", k_);
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
Main.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d%d", &i, &j), i--, j--;
      |   ^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 264 KB Output is correct
2 Correct 18 ms 280 KB Output is correct
3 Correct 26 ms 208 KB Output is correct
4 Correct 25 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
9 Correct 7 ms 208 KB Output is correct
10 Correct 12 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 13 ms 284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 264 KB Output is correct
2 Correct 18 ms 280 KB Output is correct
3 Correct 26 ms 208 KB Output is correct
4 Correct 25 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
9 Correct 7 ms 208 KB Output is correct
10 Correct 12 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 13 ms 284 KB Output is correct
13 Incorrect 0 ms 208 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 22 ms 264 KB Output is correct
10 Correct 18 ms 280 KB Output is correct
11 Correct 26 ms 208 KB Output is correct
12 Correct 25 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 10 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 5 ms 208 KB Output is correct
17 Correct 7 ms 208 KB Output is correct
18 Correct 12 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 13 ms 284 KB Output is correct
21 Incorrect 0 ms 208 KB Output isn't correct
22 Halted 0 ms 0 KB -