Submission #475237

# Submission time Handle Problem Language Result Execution time Memory
475237 2021-09-21T15:05:31 Z MohamedAhmed04 Carnival (CEOI14_carnival) C++14
100 / 100
10 ms 304 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e5 + 10 ;

int ans[MAX] ;
int n ;

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

int main()
{
	// ios_base::sync_with_stdio(0) ;
	// cin.tie(0) ;
	cin>>n ;
	vector<int>v = {1} , v2 ;
	ans[1] = 1 ;
	for(int i = 2 ; i <= n ; ++i)
	{
		v.push_back(i) ;
		int x = query(v) ;
		if(x == v.size())
		{
			ans[i] = v.size() ;
			continue ;
		}
		v.pop_back() ;
		int l = 0 , r = v.size() - 1 , idx = -1 ;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			v2.clear() ;
			for(int i = 0 ; i <= mid ; ++i)
				v2.push_back(v[i]) ;
			v2.push_back(i) ;
			if(query(v2) == v2.size() - 1)
				idx = mid , r = mid-1 ;
			else
				l = mid+1 ;
		}
		assert(idx != -1) ;
		ans[i] = ans[v[idx]] ;
	}	
	cout<<0 ;
	for(int i = 1 ; i <= n ; ++i)
		cout<<" "<<ans[i] ;
	cout<<endl ;
	return 0 ;
}		

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   if(x == v.size())
      |      ~~^~~~~~~~~~~
carnival.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    if(query(v2) == v2.size() - 1)
      |       ~~~~~~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 200 KB Output is correct
2 Correct 9 ms 200 KB Output is correct
3 Correct 8 ms 296 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 5 ms 200 KB Output is correct
6 Correct 4 ms 200 KB Output is correct
7 Correct 7 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 200 KB Output is correct
2 Correct 10 ms 200 KB Output is correct
3 Correct 4 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 6 ms 200 KB Output is correct
6 Correct 7 ms 200 KB Output is correct
7 Correct 7 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 200 KB Output is correct
2 Correct 5 ms 200 KB Output is correct
3 Correct 8 ms 200 KB Output is correct
4 Correct 4 ms 296 KB Output is correct
5 Correct 6 ms 200 KB Output is correct
6 Correct 6 ms 200 KB Output is correct
7 Correct 9 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 200 KB Output is correct
2 Correct 7 ms 200 KB Output is correct
3 Correct 6 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 8 ms 200 KB Output is correct
6 Correct 6 ms 200 KB Output is correct
7 Correct 8 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 200 KB Output is correct
2 Correct 9 ms 200 KB Output is correct
3 Correct 5 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 7 ms 200 KB Output is correct
6 Correct 5 ms 200 KB Output is correct
7 Correct 5 ms 304 KB Output is correct