Submission #751332

#TimeUsernameProblemLanguageResultExecution timeMemory
751332mariowongNizovi (COI14_nizovi)C++14
90 / 100
186 ms312 KiB
#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 timeMemoryGrader output
Fetching results...