Submission #243710

#TimeUsernameProblemLanguageResultExecution timeMemory
243710kingfran1907Nizovi (COI14_nizovi)C++14
90 / 100
220 ms416 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; int a, b; int cp(int a, int b) { printf("cmp %d %d\n", a, b); fflush(stdout); int x; scanf("%d", &x); return x; } void rev(int a, int b) { printf("reverse %d %d\n", a, b); fflush(stdout); } int main() { scanf("%d%d", &a, &b); int ptr = 0; for (int i = 1; i <= a; i++) { int lo = a + ptr; int hi = a + b; while (lo < hi) { int mid = (lo + hi + 1) / 2; if (cp(i + ptr, mid) >= 0) lo = mid; else hi = mid - 1; } if (lo == a + ptr) continue; rev(i + ptr, lo); rev(i + ptr, lo - (a - i + 1)); rev(lo - (a - i), lo); ptr += (lo - (a - i + 1)) - (i + ptr) + 1; } printf("end\n"); fflush(stdout); return 0; }

Compilation message (stderr)

nizovi.cpp: In function 'int cp(int, int)':
nizovi.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &x);
     ~~~~~^~~~~~~~~~
nizovi.cpp: In function 'int main()':
nizovi.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...