답안 #940786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
940786 2024-03-07T15:56:06 Z rainboy 마술 (GCJ14_magic) C
6 / 6
1 ms 424 KB
#include <stdio.h>

#define N	4

int main() {
	int t, _;

	scanf("%d", &t);
	for (_ = 1; _ <= t; _++) {
		int i, i_, j, a, b1, b2, b;

		scanf("%d", &i_), i_--;
		b1 = 0;
		for (i = 0; i < N; i++)
			for (j = 0; j < N; j++) {
				scanf("%d", &a);
				if (i == i_)
					b1 |= 1 << a;
			}
		scanf("%d", &i_), i_--;
		b2 = 0;
		for (i = 0; i < N; i++)
			for (j = 0; j < N; j++) {
				scanf("%d", &a);
				if (i == i_)
					b2 |= 1 << a;
			}
		b = b1 & b2;
		printf("Case #%d: ", _);
		if (b == 0)
			printf("Volunteer cheated!\n");
		else if ((b & b - 1) != 0)
			printf("Bad magician!\n");
		else {
			a = 1;
			while (1 << a != b)
				a++;
			printf("%d\n", a);
		}
	}
	return 0;
}

Compilation message

magic.c: In function 'main':
magic.c:32:19: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   32 |   else if ((b & b - 1) != 0)
      |                 ~~^~~
magic.c:8:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%d", &t);
      |  ^~~~~~~~~~~~~~~
magic.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d", &i_), i_--;
      |   ^~~~~~~~~~~~~~~~
magic.c:16:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d", &a);
      |     ^~~~~~~~~~~~~~~
magic.c:20:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%d", &i_), i_--;
      |   ^~~~~~~~~~~~~~~~
magic.c:24:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d", &a);
      |     ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 424 KB Output is correct