Submission #272143

# Submission time Handle Problem Language Result Execution time Memory
272143 2020-08-18T09:48:32 Z anubhavdhar Carnival (CEOI14_carnival) C++14
100 / 100
18 ms 416 KB
#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first 
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define FOR(i,N) for(i=0;i<(N);++i)
#define FORe(i,N) for(i=1;i<=(N);++i)
#define FORr(i,a,b) for(i=(a);i<(b);++i)
#define FORrev(i,N) for(i=(N);i>=0;--i)
#define F0R(i,N) for(int i=0;i<(N);++i)
#define F0Re(i,N) for(int i=1;i<=(N);++i)
#define F0Rr(i,a,b) for(ll i=(a);i<(b);++i)
#define F0Rrev(i,N) for(int i=(N);i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define dbgLine cerr<<" LINE : "<<__LINE__<<"\n"
#define ldd long double

using namespace std;

const int Alp = 26;
const int __PRECISION = 9;
const int inf = 1e9 + 8;

const ldd PI = acos(-1);
const ldd EPS = 1e-7;

const ll MOD = 1e9 + 7;
const ll MAXN = 2e5 + 5;
const ll ROOTN = 320;
const ll LOGN = 18;
const ll INF = 1e18 + 1022;

inline int query(int ss, int se)
{
	int s;
	cout<<se-ss+1<<' ';
	F0Rr(i, ss, se+1)
		cout<<i<<' ';
	cout<<endl;
	cin>>s;
	return s;
}

int N, col, A[200];

inline int distinct(int ss, int se)
{
	bool C[160];
	F0R(i, 160)
		C[i] = false;
	F0Rr(i, ss, se+1)
		C[A[i]] = true;
	int cnt = 0;
	F0R(i, 160)
		if(C[i])
			++cnt;
	return cnt; 
}

inline void bin_search(int tar)
{
	int mid, lo = 1, hi = tar;
	while(lo < hi - 1)
	{
		mid = (lo + hi)/2;
		if(distinct(mid,tar - 1) == query(mid, tar))	lo = mid;
		else	hi = mid;
	}
	A[tar] = A[lo];
}


signed main()
{

	/*
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	*/

	col = 1;
	int t, tmp = 1;
	cin>>N;

	A[1] = 1;
	F0Rr(i, 2, N+1)
	{
		t = query(1, i);
		if(tmp == t)	bin_search(i);
		else	A[i] = ++col;
		tmp = t;
	}

	cout<<"0 ";
	F0Re(i, N)
		cout<<A[i]<<' ';
	cout<<endl;


	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 256 KB Output is correct
2 Correct 14 ms 256 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 11 ms 256 KB Output is correct
6 Correct 11 ms 256 KB Output is correct
7 Correct 14 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 256 KB Output is correct
2 Correct 18 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 11 ms 256 KB Output is correct
6 Correct 18 ms 256 KB Output is correct
7 Correct 11 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 256 KB Output is correct
2 Correct 13 ms 256 KB Output is correct
3 Correct 10 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 10 ms 256 KB Output is correct
6 Correct 9 ms 256 KB Output is correct
7 Correct 10 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 256 KB Output is correct
2 Correct 16 ms 256 KB Output is correct
3 Correct 6 ms 416 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 12 ms 256 KB Output is correct
6 Correct 8 ms 256 KB Output is correct
7 Correct 12 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 256 KB Output is correct
2 Correct 13 ms 256 KB Output is correct
3 Correct 8 ms 256 KB Output is correct
4 Correct 9 ms 256 KB Output is correct
5 Correct 10 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct