Submission #108237

#TimeUsernameProblemLanguageResultExecution timeMemory
108237tjd229Nizovi (COI14_nizovi)C++14
100 / 100
178 ms384 KiB
#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 (stderr)

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