답안 #226762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
226762 2020-04-25T08:59:43 Z jiahng 사육제 (CEOI14_carnival) C++14
100 / 100
18 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
typedef set <int> si;
#define maxn 501

int N,C;
int ans[maxn];
int idx[maxn];

int qry(si st){
	if (st.empty()) return 0;
	cout<<st.size()<<' ';
	aFOR(i,st) cout<<i<<' ';
	cout<<'\n';
	cout.flush();
	int res;
	cin>>res;
	return res;
}

int main(){
	fast;
	
	cin>>N;
	
	si curset;
	FOR(i,1,N) curset.insert(i);
	C = qry(curset);
	
	FOR(i,1,N){
		if (curset.size() == C) break;
		curset.erase(i);
		
		if (qry(curset) != C) curset.insert(i);
	}
	
	int cnt = 1;
	aFOR(i,curset){
		ans[i] = cnt;
		idx[cnt] = i;
		//cout<<i<<' ';
		cnt++;
	}
	//cout<<'\n';
	FOR(i,1,N){
		if (curset.find(i) != curset.end()) continue;

		int l = 1, r = C + 1;
		
		while (l + 1 < r){
			int mid = (l+r)/2;
			
			//check if inside [l,mid]
			
			si qryset;
			FOR(j,l,mid) qryset.insert(idx[j]);
			qryset.insert(i);
			
			int res = qry(qryset);
			
			if (res == mid - l + 1){
				r = mid; //Inside
			}else l = mid;
		}
		
		si qryset;
		qryset.insert(i);
		qryset.insert(idx[l]);
		
		int res = qry(qryset);
		
		if (res == 1) ans[i] = l;
		else ans[i] = l+1;
		
	}
	
	cout<<0<<' ';
	FOR(i,1,N) cout<<ans[i]<<' ';
	cout<<'\n';
	cout.flush();
	
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:47:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (curset.size() == C) break;
       ~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 384 KB Output is correct
2 Correct 16 ms 384 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 12 ms 384 KB Output is correct
6 Correct 9 ms 384 KB Output is correct
7 Correct 14 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 15 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 11 ms 384 KB Output is correct
7 Correct 14 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 14 ms 384 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 11 ms 384 KB Output is correct
7 Correct 14 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 384 KB Output is correct
2 Correct 11 ms 384 KB Output is correct
3 Correct 11 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 18 ms 384 KB Output is correct
7 Correct 13 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 384 KB Output is correct
2 Correct 13 ms 384 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 14 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 14 ms 384 KB Output is correct
7 Correct 9 ms 384 KB Output is correct