Submission #992697

# Submission time Handle Problem Language Result Execution time Memory
992697 2024-06-05T03:56:44 Z aaargh Carnival (CEOI14_carnival) C++17
0 / 100
7 ms 436 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define nl '\n'
// #define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pii pair<int,int>

int query(int n, vector<int> people) {
	cout << n;
	for (int i = 0; i < n; i++) {
		cout << " " << people[i]; 
	}
	cout << endl;
	int temp;
	cin >> temp;
	return temp;
} 

void output(vector<int> v) {
	cout << 0;
	for (int e: v) cout << " " << e;
	cout << endl;
}

signed main() {
	// io;
	int n; cin >> n;
	vector<int> unique;
	unique.push_back(1);
	vector<int> costumes; 
	costumes.push_back(1);
	int prev, temp, temp2, temp3;
	//vector<int> nums;
	//nums.push_back(1);
	int maxcost = 1; 
	prev = 1;
	for (int i = 1; i < n; i++) {
		// first one is always unique
		unique.push_back(i+1);
		temp = query(unique.size(), unique);
		if (temp == prev+1) {
			// unique.push_back()
			// keep it in unique and add to costumes
			costumes.push_back(maxcost+1);
			maxcost++;
		} else {
			unique.pop_back();
			// check which one it is the same as
			int l = 0, r = unique.size()-1;
			int mid;

			while (r - l >= 1) {
				// cerr << "hi" << nl;
				mid = (l+r)/2;
				// query lower range if in or not
				vector<int> v(unique.begin()+l, unique.begin()+mid+1);
				temp2 = query(mid-l+1, v); // 0 to mid-1
				v.push_back(i+1);
				temp3 = query(mid-l+2, v);
				if (temp2  == temp3) {
					r = mid; // it could be in l to mid inclusive
				} else {
					l = mid+1; // it could be in mid+1 to r
				}
			}
			mid = (l+r)/2;
			costumes.push_back(unique[mid]);

		}
		prev = temp;
	}
	output(costumes);
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 344 KB Integer 19 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 344 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 4 ms 344 KB Integer 11 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 436 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Incorrect 7 ms 436 KB Integer 22 violates the range [1, 17]
3 Halted 0 ms 0 KB -