Submission #29577

# Submission time Handle Problem Language Result Execution time Memory
29577 2017-07-20T07:21:14 Z PrOAhMeT Carnival (CEOI14_carnival) C++14
100 / 100
26 ms 2020 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

const int MAXN=155;
int n,ans[MAXN],t;

int ask(vector<int> &v) {

	cout<<v.size();
	for(int i=0;i<v.size();++i)
		cout<<" "<<v[i];
	cout<<endl;
	int ret;
	cin>>ret;
	return ret;

}

void solve(vector<int> &v,int num) {

	if(num==1) {
		++t;
		for(int i=0;i<v.size();++i)
			ans[v[i]]=t;
		return;
	}
	vector<int> l,r;
	for(int i=0;i<v.size();++i) {
		l.pb(v[i]);
		if(ask(l)>num/2) {
			l.pop_back();
			r.pb(v[i]);
		}
	}
	solve(l,ask(l));
	solve(r,ask(r));

}

int main() {

	cin>>n;
	vector<int> v;
	for(int i=1;i<=n;++i) {
		v.pb(i);
	}
	solve(v,ask(v));
	cout<<"0";
	for(int i=1;i<=n;++i)
		cout<<" "<<ans[i];
	cout<<endl;
	return 0;

}

Compilation message

carnival.cpp: In function 'int ask(std::vector<int>&)':
carnival.cpp:17:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();++i)
               ^
carnival.cpp: In function 'void solve(std::vector<int>&, int)':
carnival.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<v.size();++i)
                ^
carnival.cpp:35:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();++i) {
               ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2020 KB Output is correct
2 Correct 3 ms 2020 KB Output is correct
3 Correct 3 ms 2020 KB Output is correct
4 Correct 9 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 3 ms 2020 KB Output is correct
7 Correct 6 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2020 KB Output is correct
2 Correct 3 ms 2020 KB Output is correct
3 Correct 3 ms 2020 KB Output is correct
4 Correct 16 ms 2020 KB Output is correct
5 Correct 13 ms 2020 KB Output is correct
6 Correct 6 ms 2020 KB Output is correct
7 Correct 9 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 3 ms 2020 KB Output is correct
3 Correct 6 ms 2020 KB Output is correct
4 Correct 13 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 3 ms 2020 KB Output is correct
7 Correct 6 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 6 ms 2020 KB Output is correct
3 Correct 3 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 9 ms 2020 KB Output is correct
6 Correct 26 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 3 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 6 ms 2020 KB Output is correct
5 Correct 6 ms 2020 KB Output is correct
6 Correct 3 ms 2020 KB Output is correct
7 Correct 6 ms 2020 KB Output is correct