Submission #1337588

#TimeUsernameProblemLanguageResultExecution timeMemory
1337588NikoBaoticNizovi (COI14_nizovi)C++20
100 / 100
47 ms440 KiB
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define F first
#define S second
#define FIO ios_base::sync_with_stdio(false); cin.tie(0)
#define sz(x) ((int)((x).size()))
#define all(x) x.begin(), x.end()
#define pb push_back
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e6 + 10;

int na, nb;

bool cmp(int a, int b) {
	if (b == na + nb + 1) return 0;
	if (a == na + nb + 1) return 1;
	if (a == b) return 0;
	cout << "cmp " << a << " " << b << endl;
	int x;
	cin >> x;
	return x == 1;
}

void rev(int a, int b) {
	if (a == b) return;
	cout << "reverse " << a << " " << b << endl;
}

int main() {
	FIO;

	cin >> na >> nb;

	int tar = na;

	for (int l = 1; l <= tar; l++) {
		if (tar + 1 == na + nb + 1) break;

		int x = tar;
		int y = na + nb + 1;

		while (x < y) {
			int mid = (x + y + 1) / 2;

			if (!cmp(l, mid)) {
				y = mid - 1;
			} else {
				x = mid;
			}
		}

		if (tar + 1 <= x) {
			int cnt = x - tar;

			rev(l, x);
			rev(l, l + cnt - 1);
			rev(l + cnt, x);
			
			l += cnt;
			tar += cnt;
		}
	}

	cout << "end" << endl;

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...