답안 #481206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481206 2021-10-19T20:04:27 Z rainboy Sob (COCI19_sob) C
110 / 110
108 ms 11092 KB
#include <stdio.h>

#define N	1000000

void solve(int *aa, int *bb, int l, int r) {
	int n = r - l, m = n / 2, i;

	if (n == 1)
		aa[0] = 0, bb[0] = l;
	else if (n % 2 == 0 && l % 2 == 0) {
		solve(aa, bb, l / 2, l / 2 + m), solve(aa + m, bb + m, l / 2, l / 2 + m);
		for (i = 0; i < n; i++)
			aa[i] <<= 1, bb[i] <<= 1;
		for (i = 0; i < m; i++)
			aa[m + i] |= 1, bb[m + i] |= 1;
	} else if (n % 2 == 0 && l % 2 == 1) {
		solve(aa, bb, l / 2, l / 2 + m), solve(aa + m, bb + m, l / 2 + 1, l / 2 + 1 + m);
		for (i = 0; i < n; i++)
			aa[i] <<= 1, bb[i] <<= 1;
		for (i = 0; i < m; i++)
			aa[i] |= 1, bb[i] |= 1;
	} else if (n % 2 == 1 && l % 2 == 0) {
		solve(aa, bb, l / 2, l / 2 + m + 1), solve(aa + m + 1, bb + m + 1, l / 2, l / 2 + m);
		for (i = 0; i < n; i++)
			aa[i] <<= 1, bb[i] <<= 1;
		for (i = 0; i < m; i++)
			aa[m + 1 + i] |= 1, bb[m + 1 + i] |= 1;
	} else {
		solve(aa, bb, l / 2, l / 2 + m + 1), solve(aa + m + 1, bb + m + 1, l / 2 + 1, l / 2 + m + 1);
		for (i = 0; i < n; i++)
			aa[i] <<= 1, bb[i] <<= 1;
		for (i = 0; i < m; i++)
			aa[m + 1 + i] |= 1, bb[m + 1 + i] |= 1;
		for (i = 0; i < m + 1; i++)
			if (bb[i] == l - 1) {
				bb[i] |= 1;
				break;
			}
	}
}

int main() {
	static int aa[N], bb[N];
	int n, m, i;

	scanf("%d%d", &n, &m);
	solve(aa, bb, m, m + n);
	for (i = 0; i < n; i++)
		printf("%d %d\n", aa[i], bb[i]);
	return 0;
}

Compilation message

sob.c: In function 'main':
sob.c:46:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 70 ms 5780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 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 55 ms 5780 KB Output is correct
7 Correct 24 ms 2884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 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 70 ms 5780 KB Output is correct
5 Correct 1 ms 332 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 0 ms 204 KB Output is correct
10 Correct 55 ms 5780 KB Output is correct
11 Correct 24 ms 2884 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 17 ms 1352 KB Output is correct
20 Correct 49 ms 4476 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 55 ms 6320 KB Output is correct
24 Correct 108 ms 11092 KB Output is correct
25 Correct 96 ms 10988 KB Output is correct