답안 #485183

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485183 2021-11-06T13:23:21 Z rainboy Nizovi (COI14_nizovi) C
100 / 100
188 ms 320 KB
#include <stdio.h>

#define N	1000

int cmp(int i, int j) {
	int x;

	printf("cmp %d %d\n", i + 1, j + 1), fflush(stdout);
	scanf("%d", &x);
	return x;
}

void rotate(int i, int n, int m) {
	if (n + m > 1)
		printf("reverse %d %d\n", i + 1, i + n + m), fflush(stdout);
	if (m > 1)
		printf("reverse %d %d\n", i + 1, i + m), fflush(stdout);
	if (n > 1)
		printf("reverse %d %d\n", i + m + 1, i + n + m), fflush(stdout);
}

int main() {
	static int jj[N];
	int na, nb, i, j;

	scanf("%d%d", &na, &nb);
	for (i = 0; i < na; i++) {
		int lower = -1, upper = nb;

		while (upper - lower > 1) {
			j = (lower + upper) / 2;
			if (cmp(na + j, i) < 0)
				lower = j;
			else
				upper = j;
		}
		jj[i] = upper;
	}
	for (i = 0, j = 0; i < na; i++)
		if (j < jj[i])
			rotate(i + j, na - i, jj[i] - j), j = jj[i];
	printf("end\n"), fflush(stdout);
	return 0;
}

Compilation message

nizovi.c: In function 'cmp':
nizovi.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &x);
      |  ^~~~~~~~~~~~~~~
nizovi.c: In function 'main':
nizovi.c:26:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d%d", &na, &nb);
      |  ^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 3 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 42 ms 264 KB Output is correct
5 Correct 23 ms 200 KB Output is correct
6 Correct 30 ms 200 KB Output is correct
7 Correct 178 ms 320 KB Output is correct
8 Correct 188 ms 272 KB Output is correct
9 Correct 175 ms 256 KB Output is correct
10 Correct 183 ms 272 KB Output is correct