Submission #234949

# Submission time Handle Problem Language Result Execution time Memory
234949 2020-05-26T12:02:38 Z spacewalker Nizovi (COI14_nizovi) C++14
0 / 100
213 ms 504 KB
#include <bits/stdc++.h>

using namespace std;

int cmp(int x, int y) {
	printf("cmp %d %d\n", x + 1, y + 1);
	fflush(stdout);
	int ret; scanf("%d", &ret);
	return ret;
}

void reverse(int x, int y) {
	if (x > y) return;
	printf("reverse %d %d\n", x + 1, y + 1);
	fflush(stdout);
}

void end() {
	printf("end\n");
	fflush(stdout);
	exit(0);
}

int main() {
	int aLen, bLen; scanf("%d %d", &aLen, &bLen);
	vector<int> posInB(aLen);
	for (int i = 0; i < aLen; ++i) {
		int lo = 0, hi = bLen - 1;
		while (lo < hi) {
			int mid = lo + (hi - lo) / 2;
			if (cmp(i, aLen + mid) < 1) hi = mid;
			else lo = mid + 1;
		}
		if (cmp(i, aLen + lo) < 1) posInB[i] = aLen + lo;
		else posInB[i] = aLen + bLen;
//		printf("%d should be injected before %d\n", i, posInB[i]);
	}
	int cAStart = 0, cBStart = aLen;
	for (int i = 0; i < aLen; ++i) {
		int injectPoint = posInB[i];
		int spanLenB = injectPoint - cBStart;
		int curALen = aLen - i;
		reverse(cAStart, injectPoint - 1);
		reverse(cAStart, cAStart + spanLenB - 1);
		reverse(cAStart + spanLenB, injectPoint - 1);
		cAStart = injectPoint, cBStart = cAStart + curALen;
	}
	end();
	return 0;
}

Compilation message

nizovi.cpp: In function 'int cmp(int, int)':
nizovi.cpp:8:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int ret; scanf("%d", &ret);
           ~~~~~^~~~~~~~~~~~
nizovi.cpp: In function 'int main()':
nizovi.cpp:25:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int aLen, bLen; scanf("%d %d", &aLen, &bLen);
                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Incorrect
2 Incorrect 7 ms 256 KB Incorrect
3 Incorrect 8 ms 256 KB Incorrect
4 Incorrect 52 ms 372 KB Incorrect
5 Incorrect 52 ms 368 KB Incorrect
6 Incorrect 46 ms 376 KB Incorrect
7 Incorrect 202 ms 372 KB Incorrect
8 Incorrect 182 ms 376 KB Incorrect
9 Incorrect 206 ms 504 KB Incorrect
10 Incorrect 213 ms 376 KB Incorrect