Submission #709969

# Submission time Handle Problem Language Result Execution time Memory
709969 2023-03-15T02:12:43 Z TranGiaHuy1508 Carnival (CEOI14_carnival) C++17
0 / 100
8 ms 304 KB
#include <bits/stdc++.h>
using namespace std;

void main_program();

signed main(){
	main_program();
}

int ask(vector<int> &V){
	if (V.empty()) return 0;
	cout << V.size();
	for (auto i: V) cout << " " << i+1;
	cout << "\n"; cout.flush();
	int res; cin >> res; return res;
}

void main_program(){
	int n; cin >> n;

	int prev = 0;
	vector<int> query = {};
	vector<int> f = {};

	for (int i = 0; i < n; i++){
		query.push_back(i);
		int val = ask(query);

		if (val > prev){
			f.push_back(i);
			prev = val;
		}
	}

	vector<int> arrow(n, -2);
	for (auto i: f) arrow[i] = -1;

	for (int i = 0; i < n; i++){
		if (arrow[i] != -2) continue;
		int l = 0, r = f.size() - 1;
		while (l < r){
			int mid = (l + r) >> 1;

			vector<int> query2;
			for (int j = 0; j <= mid; j++) query2.push_back(f[j]);
			query2.push_back(i);

			if (ask(query2) == (int)query2.size()) l = mid+1;
			else r = mid;
		}
		arrow[i] = l;
	}

	vector<int> num(n, 0);
	for (int i = 0; i < (int)f.size(); i++) num[f[i]] = i+1;

	for (int i = 0; i < n; i++){
		if (!num[i]) num[i] = num[arrow[i]];
	}

	cout << 0;
	for (int i = 0; i < n; i++) cout << " " << num[i];
	cout << "\n"; cout.flush();
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 300 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Incorrect 5 ms 208 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 296 KB Output is correct
2 Incorrect 8 ms 304 KB Incorrect
3 Halted 0 ms 0 KB -