제출 #36409

#제출 시각아이디문제언어결과실행 시간메모리
36409mohammad_kilani사육제 (CEOI14_carnival)C++14
100 / 100
43 ms3188 KiB
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define oo 2000000000
const int N = 300010;
int num[N];

int ask(int l,int r){
	if(r == l) return 1;
	printf("%d",r-l+1);
	for(int i=l;i<=r;i++) printf(" %d",i);
	puts("");
	fflush(stdout);
	int res ;
	scanf("%d",&res);
	return res;
}
 
int main() {
	//freopen("in.txt","r",stdin);
	int n , cnt = 1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		if(num[i] == 0){
			num[i] = cnt++;
		}
		int low = i + 1, high = n , res = i;
		while(high >= low){
			int mid = (low + high) / 2;
			int cur = ask(i,mid);
			int cur2 = ask(i+1,mid);
			if(cur == cur2){
				res = mid;
				high = mid - 1;
			}
			else{
				low = mid + 1;
			}
		}
		num[res] = num[i];
	}
	putchar('0');
	for(int i=1;i<=n;i++) printf(" %d",num[i]);
	puts("");
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

carnival.cpp: In function 'int ask(int, int)':
carnival.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&res);
                  ^
carnival.cpp: In function 'int main()':
carnival.cpp:22:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...