답안 #155006

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155006 2019-09-25T21:04:49 Z TadijaSebez 사육제 (CEOI14_carnival) C++11
100 / 100
15 ms 396 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int Ask(vector<int> v, int n)
{
	printf("%i ",n);
	for(int i=0;i<n;i++) printf("%i ",v[i]);
	printf("\n");
	fflush(stdout);
	int b;scanf("%i",&b);
	return b;
}
int Ask(vector<int> v, int n, int x)
{
	printf("%i ",n+1);
	for(int i=0;i<n;i++) printf("%i ",v[i]);
	printf("%i\n",x);
	fflush(stdout);
	int b;scanf("%i",&b);
	return b;
}
const int N=155;
int col[N];
int main()
{
	int n;
	scanf("%i",&n);
	vector<int> all,fir,work;
	for(int i=1;i<=n;i++) all.pb(i);
	int pre=0;
	for(int i=1;i<=n;i++)
	{
		int now=Ask(all,i);
		if(now!=pre) fir.pb(i),col[i]=fir.size();
		else work.pb(i);
		pre=now;
	}
	for(int x:work)
	{
		int top=fir.size(),bot=1,mid,ans=fir.size();
		while(top>=bot)
		{
			mid=top+bot>>1;
			if(Ask(fir,mid,x)==mid) top=mid-1,ans=mid;
			else bot=mid+1;
		}
		col[x]=ans;
	}
	printf("0 ");
	for(int i=1;i<=n;i++) printf("%i ",col[i]);
	printf("\n");
	fflush(stdout);
	return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:43:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    mid=top+bot>>1;
        ~~~^~~~
carnival.cpp: In function 'int Ask(std::vector<int>, int)':
carnival.cpp:10:13: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int b;scanf("%i",&b);
        ~~~~~^~~~~~~~~
carnival.cpp: In function 'int Ask(std::vector<int>, int, int)':
carnival.cpp:19:13: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int b;scanf("%i",&b);
        ~~~~~^~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 296 KB Output is correct
2 Correct 13 ms 376 KB Output is correct
3 Correct 10 ms 248 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 7 ms 248 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 248 KB Output is correct
2 Correct 12 ms 376 KB Output is correct
3 Correct 5 ms 396 KB Output is correct
4 Correct 7 ms 392 KB Output is correct
5 Correct 10 ms 376 KB Output is correct
6 Correct 8 ms 244 KB Output is correct
7 Correct 15 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 10 ms 248 KB Output is correct
3 Correct 12 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 7 ms 376 KB Output is correct
6 Correct 10 ms 376 KB Output is correct
7 Correct 13 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 376 KB Output is correct
2 Correct 9 ms 248 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 12 ms 248 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 11 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 248 KB Output is correct
2 Correct 13 ms 376 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
4 Correct 10 ms 376 KB Output is correct
5 Correct 6 ms 248 KB Output is correct
6 Correct 9 ms 296 KB Output is correct
7 Correct 6 ms 248 KB Output is correct