답안 #225950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225950 2020-04-22T04:53:06 Z bensonlzl 사육제 (CEOI14_carnival) C++14
100 / 100
12 ms 512 KB
#include <bits/stdc++.h>

using namespace std;

int colour[205], c;
vector<int> distinct;
int N;

int query(vector<int> q){
	int x;
	cout << q.size() << ' ';
	for (auto it : q){
		cout << it << ' ';
	}
	cout << '\n' << flush;
	cin >> x;
	return x;
}

int find_colour(int x, vector<int> v){
	if (v.size() == 1){
		return colour[v[0]];
	}
	vector<int> v1, v2;
	for (int i = 0; i < v.size(); ++i){
		if (i%2==0) v1.push_back(v[i]);
		else v2.push_back(v[i]);
	}
	v1.push_back(x);
	int a2 = query(v1);
	v1.pop_back();
	if (a2 == v1.size()) return find_colour(x,v1);
	else return find_colour(x,v2);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; ++i){
		distinct.push_back(i);
		int d = query(distinct);
		if (d != distinct.size()){
			distinct.pop_back();
		}
		else{
			colour[i] = ++c;
		}

	}
	for (int i = 1; i <= N; ++i){
		if (!colour[i]){
			colour[i] = find_colour(i,distinct);
		}
	}
	cout << "0 ";
	for (int i = 1; i <= N; ++i){
		cout << colour[i] << ' ';
	}
	cout << '\n';
}

Compilation message

carnival.cpp: In function 'int find_colour(int, std::vector<int>)':
carnival.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < v.size(); ++i){
                  ~~^~~~~~~~~~
carnival.cpp:32:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (a2 == v1.size()) return find_colour(x,v1);
      ~~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:43:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (d != distinct.size()){
       ~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 384 KB Output is correct
2 Correct 11 ms 384 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 11 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 11 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 10 ms 384 KB Output is correct
6 Correct 11 ms 384 KB Output is correct
7 Correct 11 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 12 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 11 ms 384 KB Output is correct
6 Correct 12 ms 384 KB Output is correct
7 Correct 12 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 384 KB Output is correct
6 Correct 11 ms 384 KB Output is correct
7 Correct 8 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 12 ms 384 KB Output is correct
3 Correct 8 ms 396 KB Output is correct
4 Correct 9 ms 512 KB Output is correct
5 Correct 11 ms 384 KB Output is correct
6 Correct 9 ms 384 KB Output is correct
7 Correct 8 ms 384 KB Output is correct