답안 #317983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
317983 2020-10-31T04:16:23 Z nandonathaniel 사육제 (CEOI14_carnival) C++14
100 / 100
37 ms 384 KB
#include<bits/stdc++.h>
using namespace std;

int ans[155],x;

int tanya(int l,int r){
	cout << r-l+1;
	for(int i=l;i<=r;i++){
		cout << " " << i;
	}
	cout << endl;
	cin >> x;
	return x;
}

bool valid(int l,int r){
	int y=tanya(l,r);
	set<int> S;
	for(int i=l;i<r;i++)S.insert(ans[i]);
	return S.size()==y;
}

int main(){
	int n,x;
	cin >> n;
	ans[1]=1;
	int last=1,no=1;
	for(int i=2;i<=n;i++){
		int x=tanya(1,i);
		if(x>last){
			no++;
			ans[i]=no;
			last=x;
			continue;
		}
		int ki=1,ka=i-1,res;
		while(ki<=ka){
			int mid=(ki+ka)/2;
			if(valid(mid,i)){
				res=mid;
				ki=mid+1;
			}
			else ka=mid-1;
		}
		ans[i]=ans[res];
	}
	cout << 0;
	for(int i=1;i<=n;i++)cout << " " << ans[i];
	cout << endl;
	return 0;
}

Compilation message

carnival.cpp: In function 'bool valid(int, int)':
carnival.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |  return S.size()==y;
      |         ~~~~~~~~^~~
carnival.cpp: In function 'int main()':
carnival.cpp:24:8: warning: unused variable 'x' [-Wunused-variable]
   24 |  int n,x;
      |        ^
carnival.cpp:45:17: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |   ans[i]=ans[res];
      |          ~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 256 KB Output is correct
2 Correct 11 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 14 ms 256 KB Output is correct
6 Correct 12 ms 256 KB Output is correct
7 Correct 37 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 256 KB Output is correct
2 Correct 14 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 11 ms 256 KB Output is correct
7 Correct 8 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 256 KB Output is correct
2 Correct 13 ms 256 KB Output is correct
3 Correct 10 ms 380 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 10 ms 256 KB Output is correct
6 Correct 11 ms 256 KB Output is correct
7 Correct 9 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 256 KB Output is correct
2 Correct 14 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 9 ms 256 KB Output is correct
6 Correct 8 ms 256 KB Output is correct
7 Correct 15 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 256 KB Output is correct
2 Correct 17 ms 288 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
4 Correct 8 ms 256 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct