# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
751332 | mariowong | Nizovi (COI14_nizovi) | C++14 | 186 ms | 312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
int n,m;
cin >> n >> m;
int cnt=0;
for (int i=1;i<=n;i++){
int x;
int L=cnt+n+1,R=n+m;
while (L < R){
int mid=(L+R+1)/2;
cout << "cmp " << cnt+i << " " << mid << "\n";
fflush(stdout);
cin >> x;
if (x == -1) R=mid-1;
else L=mid;
}
if (L == cnt+n+1){
cout << "cmp " << cnt+i << " " << cnt+n+1 << "\n";
fflush(stdout);
cin >> x;
if (x == -1) continue;
}
int num=L-(cnt+n);
if (cnt+i < cnt+n) cout << "reverse " << cnt+i << " " << cnt+n << "\n";
if (cnt+i < cnt+n) fflush(stdout);
if (cnt+i < L) cout << "reverse " << cnt+i << " " << L << "\n";
if (cnt+i < L) fflush(stdout);
if (cnt+i < cnt+i+num-1) cout << "reverse " << cnt+i << " " << cnt+i+num-1 << "\n";
if (cnt+i < cnt+i+num-1) fflush(stdout);
cnt+=num;
if (cnt == m) break;
}
cout << "end\n";
fflush(stdout);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |