Submission #113669

# Submission time Handle Problem Language Result Execution time Memory
113669 2019-05-27T15:46:42 Z Adhyyan1252 Carnival (CEOI14_carnival) C++11
100 / 100
14 ms 408 KB
#include<bits/stdc++.h>

using namespace std;

int query(const vector<int>& a){
	if(a.size() == 0) return 0;
	cout<<a.size()<<endl;
	for(int b: a) cout<<b+1<<" ";
	cout<<endl;
	int ret; cin>>ret;
	return ret;
}

int main(){
	int n; cin>>n;
	vector<int> a(n, -1);
	a[0] = 1;
	int pntr = 2;
	vector<int> diff; diff.push_back(0);
	for(int i = 1; i < n; i++){
		int low = 0, high = diff.size()-1, mid;
		vector<int> c(diff); c.push_back(i);
		if(query(c) == c.size()){
			//this is a new one
			a[i]= pntr; pntr++;
			diff.push_back(i);
			continue;
		}
		while(low < high){
			mid = (low + high)/2;
			vector<int> b(diff.begin() + low, diff.begin() + mid + 1);
			b.push_back(i);
			int q = query(b);
			if(q == (int)(b.size()-1)){
				//means that they share the shit
				high = mid;
			}else{
				low = mid+1;
			}
		}
		mid = (low + high)/2;
		a[i] = a[diff[mid]];
	}
	cout<<0<<" ";
	for(int i = 0; i < n; i++) cout<<a[i]<<" ";
	cout<<endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:23:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(query(c) == c.size()){
      ~~~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 304 KB Output is correct
2 Correct 8 ms 256 KB Output is correct
3 Correct 4 ms 404 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 8 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 356 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 12 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 4 ms 408 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 11 ms 256 KB Output is correct
6 Correct 7 ms 256 KB Output is correct
7 Correct 14 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 9 ms 256 KB Output is correct
3 Correct 12 ms 256 KB Output is correct
4 Correct 8 ms 304 KB Output is correct
5 Correct 5 ms 324 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 4 ms 324 KB Output is correct