답안 #949793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949793 2024-03-19T17:48:55 Z rainboy 양말 찾기 (KPI13_socks) C
0 / 1
2426 ms 37200 KB
#include <stdio.h>
 
#define L	31	/* L = ceil(log2(2 * 10^9 + 1)) */
 
int main() {
	static int xx[L];
	int n, l, a, b, x, tmp;
 
	scanf("%d", &n);
	x = 0;
	while (n--) {
		scanf("%d", &a);
		x ^= a;
		for (l = 0; l < L; l++)
			if ((a & 1 << l) != 0)
				xx[l] ^= a;
	}
	a = 0, b = x;
	for (l = 0; l < L; l++)
		if (xx[l] != 0 && xx[l] != x) {
			a = xx[l], b = x ^ xx[l];
			break;
		}
	if (a > b)
		tmp = a, a = b, b = tmp;
	printf("%d %d\n", a, b);
	return 0;
}

Compilation message

socks.c: In function 'main':
socks.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
socks.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d", &a);
      |   ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2426 ms 388 KB Output is correct
12 Correct 2415 ms 388 KB Output is correct
13 Runtime error 2401 ms 37200 KB Memory limit exceeded
14 Halted 0 ms 0 KB -