#include <ctype.h>
#include <stdio.h>
#define L 31 /* L = ceil(log2(2 * 10^9 + 1)) */
char c; int sgn;
void read(int *a) {
while (1)
if (isdigit(c = getchar()) || c == '-')
break;
sgn = 1;
if (c == '-')
sgn = -1, c = getchar();
*a = 0;
for ( ; isdigit(c); c = getchar())
*a = *a * 10 + c - '0';
*a *= sgn;
}
int main() {
static int xx[L];
int n, l, a, b, x, tmp;
read(&n);
x = 0;
while (n--) {
read(&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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 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 |
0 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 |
1 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 |
1769 ms |
396 KB |
Output is correct |
12 |
Runtime error |
1781 ms |
36744 KB |
Memory limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |