Submission #715334

# Submission time Handle Problem Language Result Execution time Memory
715334 2023-03-26T13:49:59 Z study Carnival (CEOI14_carnival) C++17
100 / 100
9 ms 316 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 151;

int color[N];
vector<int> people;

int query(vector<int>& v){
	cout << v.size();
	for (int i:v) cout << ' ' << i;
	cout << endl;
	int a;
	cin >> a;
	return a;
}

int query(int deb, int fin, int pos){
	cout << fin-deb+2;
	for (int i=deb; i<=fin; ++i){
		cout << ' ' << people[i];
	}
	cout << ' ' << pos;
	cout << endl;
	int a;
	cin >> a;
	return a;
}

void dc(int deb, int fin, int pos){
	if (deb == fin){
		color[pos] = color[people[deb]];
		return;
	}
	int mid = (deb+fin)/2;
	if (query(deb,mid,pos) == mid-deb+1){
		dc(deb,mid,pos);
	}
	else dc(mid+1,fin,pos);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int prev = 0;
	for (int i=1; i<=n; ++i){
		people.emplace_back(i);
		if (query(people) != prev+1){
			people.pop_back();
		}
		else prev++;
	}
	int ans = 1;
	for (int i:people){
		color[i] = ans;
		ans++;
	}
	for (int i=1; i<=n; ++i){
		if (color[i] == 0){
			dc(0,people.size()-1,i);
		}
	}
	cout << 0;
	for (int i=1; i<=n; ++i){
		cout << ' ' << color[i];
	}
	cout << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 5 ms 288 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 3 ms 316 KB Output is correct