Submission #743428

# Submission time Handle Problem Language Result Execution time Memory
743428 2023-05-17T11:35:40 Z NintsiChkhaidze Carnival (CEOI14_carnival) C++17
100 / 100
10 ms 328 KB
#include <bits/stdc++.h>
#define ll long long
#define s second
#define pb push_back
#define f first
using namespace std;
 
const int N = 205;

int a[N],c[N],arr[N];
bool f[N];

int query(int l,int r,int x){
	cout<<r - l + 2<<" ";
	for (int i = l; i <= r; i++)
		cout<<a[i]<<" ";
	cout<<x<<endl;
	int k;
	cin>>k;
	return k;
}
signed main (){
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    
    int n;
    cin>>n;
	int m = 1;
	a[1] = 1;
	f[1] = 1;
	
	for (int i = 2; i <= n; i++){
		int k = query(1,m,i);
		if (k == m + 1){
			++m;
			a[m] = i;
			f[i] = 1;
		}
	}    
	
	for (int i = 1; i <= m; i++)
		c[a[i]] = i;
	
	for (int i = 1; i <= n; i++){
		if (f[i]) continue;
		int res=0,l = 1,r = m;
		
		while (l <= r){
			int mid = (l + r)>>1;
			int k = query(l,mid,i);
			if (l == r && k == 1) {
				res = l;
				break;
			}
			if (k == mid - l + 2){
				l = mid + 1;
			}else{
				r = mid;
			}
		}
		
		c[i] = c[a[res]];
	}
	cout<<0<<" ";
	for (int i = 1; i <= n; i++)
		cout<<c[i]<<" ";
	cout<<endl;
}

# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 4 ms 320 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 4 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 7 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 8 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 7 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 7 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 10 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 7 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 6 ms 328 KB Output is correct
7 Correct 3 ms 208 KB Output is correct