답안 #29576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29576 2017-07-20T07:18:00 Z PrOAhMeT 사육제 (CEOI14_carnival) C++14
0 / 100
0 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) {

	printf("%d",(int)v.size());
	for(int i=0;i<v.size();++i)
		printf(" %d",v[i]);
	fflush(stdout);
	int ret;
	scanf("%d",&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() {

	scanf("%d",&n);
	vector<int> v;
	for(int i=1;i<=n;++i) {
		v.pb(i);
	}
	solve(v,ask(v));
	printf("0");
	for(int i=1;i<=n;++i)
		printf(" %d",ans[i]);
	fflush(stdout);
	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) {
               ^
carnival.cpp: In function 'int ask(std::vector<int>&)':
carnival.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&ret);
                  ^
carnival.cpp: In function 'int main()':
carnival.cpp:49:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 2020 KB Execution timed out (wall clock limit exceeded)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 2020 KB Execution timed out (wall clock limit exceeded)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 2020 KB Execution timed out (wall clock limit exceeded)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 2020 KB Execution timed out (wall clock limit exceeded)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 2020 KB Execution timed out (wall clock limit exceeded)
2 Halted 0 ms 0 KB -