Submission #995862

# Submission time Handle Problem Language Result Execution time Memory
995862 2024-06-10T03:07:15 Z BuzzyBeez Carnival (CEOI14_carnival) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

int n, res;
vector<int> v;
set<int> rem;
int a[200];

int ask(int l, int lim) {
	for (int i = l; i <= lim; ++i) if (!a[i]) cout << i << ' ';
	cout << endl;
	cin >> res; return res;
}

void answer() {
	cout << 0 << ' ';
	for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
	cout << endl;
}

signed main() {
	cin >> n; int l, r, mid, pt, num = 1, m;
	v.resize(n + 1); iota(v.begin(), v.end(), 0);
	for (int i = 1; i <= n; ++i) rem.insert(i);
	while (rem.size()) {
		pt = 0; m = *prev(rem.end());
		// cout << "Remaining : ";
		// for (int i : rem) cout << i << ' ';
		// cout << endl;
		if (ask(1, m) == 1) {
			for (int i : rem) a[i] = num;
			break;
		}
		while (pt < m) {
			if (ask(1, m - 1) < ask(1, m)) pt = m;
			else {
				l = pt + 1; r = m;
				while (l <= r) {
					mid = (l + r) / 2;
					if (ask(mid, m - 1) < ask(mid, m)) r = mid - 1;
					else l = mid + 1;
				}
				pt = r; 
			}
			a[pt] = num; rem.erase(pt);
			// cout << "found " << pt << " : " << a[pt] << "!!" << endl;
		}
		++num;
	}
	answer();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 0 violates the range [1, 137]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 0 violates the range [1, 145]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 0 violates the range [1, 133]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 0 violates the range [1, 143]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 0 violates the range [1, 149]
2 Halted 0 ms 0 KB -