Submission #625199

#TimeUsernameProblemLanguageResultExecution timeMemory
625199MilosMilutinovicNizovi (COI14_nizovi)C++14
100 / 100
192 ms336 KiB
/** * author: wxhtzdy * created: 09.08.2022 16:41:55 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int na, nb; cin >> na >> nb; auto Ask = [&](int i, int j) { cout << "cmp " << i << " " << j << endl; int x; cin >> x; return x; }; vector<int> at(na); for (int i = 0; i < na; i++) { int low = 1, high = nb; while (low <= high) { int mid = low + high >> 1; if (Ask(i + 1, na + mid) > 0) { at[i] = mid; low = mid + 1; } else { high = mid - 1; } } } auto Reverse = [&](int pos, int la, int lb) { assert(la >= 1 && lb >= 1); cout << "reverse " << pos << " " << pos + la + lb - 1 << endl; if (la > 1) { cout << "reverse " << pos + lb << " " << pos + la + lb - 1 << endl; } if (lb > 1) { cout << "reverse " << pos << " " << pos + lb - 1 << endl; } }; int ptr = 0; for (int i = 0; i < na; i++) { if (ptr < at[i]) { Reverse(i + 1 + ptr, na - i, at[i] - ptr); ptr = at[i]; } } cout << "end" << endl; return 0; }

Compilation message (stderr)

nizovi.cpp: In function 'int main()':
nizovi.cpp:24:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |       int mid = low + high >> 1;
      |                 ~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...