Submission #108219

# Submission time Handle Problem Language Result Execution time Memory
108219 2019-04-28T08:29:49 Z tjd229 Nizovi (COI14_nizovi) C++14
90 / 100
225 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 = l, 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);
                 ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 34 ms 256 KB Output is correct
5 Correct 27 ms 384 KB Output is correct
6 Correct 33 ms 256 KB Output is correct
7 Correct 225 ms 256 KB Output is correct
8 Correct 158 ms 384 KB Output is correct
9 Correct 153 ms 296 KB Output is correct
10 Incorrect 181 ms 304 KB Total cost of reverse commands > 3 000 000