Submission #234955

#TimeUsernameProblemLanguageResultExecution timeMemory
234955spacewalkerNizovi (COI14_nizovi)C++14
90 / 100
168 ms504 KiB
#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; // fprintf(stderr, "%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; // fprintf(stderr, "[%d len %d][%d len %d](ip %d)\n", cAStart, curALen, cBStart, spanLenB, injectPoint); reverse(cAStart, injectPoint - 1); reverse(cAStart, cAStart + spanLenB - 1); reverse(cAStart + spanLenB, injectPoint - 1); cAStart += spanLenB + 1; cBStart = cAStart + curALen - 1; } end(); return 0; }

Compilation message (stderr)

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 timeMemoryGrader output
Fetching results...