답안 #108237

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
108237 2019-04-28T10:30:32 Z tjd229 Nizovi (COI14_nizovi) C++14
100 / 100
178 ms 384 KB
#include <stdio.h>
int _cmp(int X,int Y) {
	if (X == Y) return 0;
	printf("cmp %d %d\n", X, Y); fflush(stdout);
	int res; scanf("%d",&res);
	return res;
}
void _rev(int X,int Y) {
	if (X < Y) {
		printf("reverse %d %d\n", X, Y); fflush(stdout);
	}
}
int main() {
	int Na, Nb, i; scanf("%d%d",&Na,&Nb);
	int l, r;
	int sa = 1, sb = 1;
	int X, Y;
	int aix = 1, bix = Na + 1;
 
	while (bix<=Na+Nb && _cmp(bix-1,bix)>0) {
		while (sa < Na && _cmp(aix, bix) <= 0) ++aix, ++sa;
      	while (sa < Na && _cmp(aix, aix+1) == 0) ++aix, ++sa;
		l = bix, r = Na + Nb;
		Y = l;
		while (l <= r) {
			int m = (l + r) >> 1;
			if (_cmp(aix, m) < 0) r = m - 1;
			else Y = m, l = m + 1;
		}
		_rev(aix, Y); _rev(aix, aix+Y - bix); _rev(aix+Y-bix+1, Y);
		aix += Y - bix + 1;
		bix = Y + 1;
	}
	printf("end\n"); fflush(stdout);
	
	return 0;
}

Compilation message

nizovi.cpp: In function 'int main()':
nizovi.cpp:14:14: warning: unused variable 'i' [-Wunused-variable]
  int Na, Nb, i; scanf("%d%d",&Na,&Nb);
              ^
nizovi.cpp:16:14: warning: unused variable 'sb' [-Wunused-variable]
  int sa = 1, sb = 1;
              ^~
nizovi.cpp:17:6: warning: unused variable 'X' [-Wunused-variable]
  int X, Y;
      ^
nizovi.cpp: In function 'int _cmp(int, int)':
nizovi.cpp:5:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int res; scanf("%d",&res);
           ~~~~~^~~~~~~~~~~
nizovi.cpp: In function 'int main()':
nizovi.cpp:14:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int Na, Nb, i; scanf("%d%d",&Na,&Nb);
                 ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 22 ms 256 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 13 ms 256 KB Output is correct
7 Correct 113 ms 256 KB Output is correct
8 Correct 151 ms 256 KB Output is correct
9 Correct 142 ms 376 KB Output is correct
10 Correct 178 ms 300 KB Output is correct