답안 #785000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785000 2023-07-16T22:01:59 Z rainboy Xor Sort (eJOI20_xorsort) C
65 / 100
5 ms 852 KB
#include <stdio.h>

#define N	1000
#define L	20
#define M	40000

int aa[N], ii[M], jj[M], m;

void move(int i, int j) {
	ii[m] = i, jj[m] = j, m++;
	aa[i] ^= aa[j];
}

int main() {
	int n, t, h, i, j, l;

	scanf("%d%d", &n, &t);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	if (t == 1)
		for (i = 0; i < n; i++)
			for (j = i; j > 0 && aa[j] < aa[j - 1]; j--)
				move(j, j - 1), move(j - 1, j), move(j, j - 1);
	else if (t == 2)
		for (l = L - 1; l >= 0; l--) {
			for (i = 0; i + 1 < n; i++)
				if ((aa[i] & 1 << l) != 0) {
					if ((aa[i + 1] & 1 << l) == 0)
						move(i + 1, i);
					move(i, i + 1);
				}
			if ((aa[n - 1] & 1 << l) != 0)
				n--;
		}
	printf("%d\n", m);
	for (h = 0; h < m; h++)
		printf("%d %d\n", ii[h] + 1, jj[h] + 1);
	return 0;
}

Compilation message

xorsort.c: In function 'main':
xorsort.c:17:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d%d", &n, &t);
      |  ^~~~~~~~~~~~~~~~~~~~~
xorsort.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 284 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 540 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 4 ms 724 KB Output is correct
13 Correct 4 ms 724 KB Output is correct
14 Correct 4 ms 724 KB Output is correct
15 Correct 4 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 284 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 540 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 4 ms 724 KB Output is correct
13 Correct 4 ms 724 KB Output is correct
14 Correct 4 ms 724 KB Output is correct
15 Correct 4 ms 724 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 4 ms 724 KB Output is correct
19 Correct 4 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 4 ms 724 KB Output is correct
22 Correct 4 ms 724 KB Output is correct
23 Correct 5 ms 724 KB Output is correct
24 Correct 5 ms 668 KB Output is correct
25 Correct 4 ms 596 KB Output is correct
26 Incorrect 5 ms 852 KB Integer 40572 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 5 ms 724 KB Output is correct
6 Correct 4 ms 688 KB Output is correct
7 Correct 4 ms 680 KB Output is correct
8 Correct 5 ms 724 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 4 ms 744 KB Output is correct
11 Correct 4 ms 724 KB Output is correct
12 Correct 4 ms 724 KB Output is correct
13 Correct 4 ms 732 KB Output is correct
14 Correct 4 ms 724 KB Output is correct
15 Correct 5 ms 852 KB Output is correct