답안 #67239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67239 2018-08-13T17:17:11 Z KLPP 사육제 (CEOI14_carnival) C++14
0 / 100
4 ms 824 KB
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int n;
int pergunta(vector<int> a){cout<<a.size()<<" ";
	for(int i=0;i<a.size();i++)cout<<a[i]<<" ";
	cout<<endl;
	int x;
	cin>>x;
	return x;
}
vector<int> ans(int i, int j){
	if(i==j){
		vector<int>v;
		v.push_back(j);
		return v;
	}
	int mid=(i+j)/2;
	vector<int> v1=ans(i,mid);
	vector<int> v2=ans(mid+1,j);
	vector<pair<int,int> >V;
	int cnt[n];
	for(int x=0;x<n;x++)cnt[x]=-1;
	for(int person=0;person<v2.size();person++){
		cnt[v2[person]]=person+mid+1;
		//cout<<v2[person]<<" "<<person+mid+1<<endl;
	}
	vector<int> responde;
	for(int x=0;x<v1.size();x++){
		int cor=0;
		for(int bit=0;bit<9;bit++){vector<int> festa;
			for(int y=0;y<n;y++){
				if((y>>bit)%2==0 && cnt[y]!=-1){
					festa.push_back(cnt[y]);
				}
			}
			festa.push_back(x+i);
			int R=pergunta(festa);
			if(R==festa.size())cor+=(1<<bit);
		}
		if(cor<=n){
			responde.push_back(cor);
		}else responde.push_back(v1[i]);
	}
	for(int person=0;person<v2.size();person++){
		responde.push_back(v2[i]);
	}
	return responde;
}
int main(){
	cin>>n;
	vector<int> V=ans(0,n-1);
	//for(int i=0;i<V.size();i++)cout<<V[i]<<endl;
	vector<pair<int,int> > v;
	for(int i=0;i<V.size();i++){
		v.push_back(pair<int,int>(V[i],i));
	}sort(v.begin(),v.end());
	int color=0;
	int arr[n];
	for(int i=0;i<v.size();i++){
		if(i==0 || v[i].first!=v[i-1].first){
			color++;
		}arr[v[i].second]=color;
	}
	for(int i=0;i<n;i++)cout<<arr[i]<<" ";
	cout<<endl;
	return 0;
}

Compilation message

carnival.cpp: In function 'int pergunta(std::vector<int>)':
carnival.cpp:8:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<a.size();i++)cout<<a[i]<<" ";
              ~^~~~~~~~~
carnival.cpp: In function 'std::vector<int> ans(int, int)':
carnival.cpp:26:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int person=0;person<v2.size();person++){
                   ~~~~~~^~~~~~~~~~
carnival.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int x=0;x<v1.size();x++){
              ~^~~~~~~~~~
carnival.cpp:41:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(R==festa.size())cor+=(1<<bit);
       ~^~~~~~~~~~~~~~
carnival.cpp:47:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int person=0;person<v2.size();person++){
                   ~~~~~~^~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:57:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size();i++){
              ~^~~~~~~~~
carnival.cpp:62:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();i++){
              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 416 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 624 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -