답안 #68642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68642 2018-08-17T18:34:36 Z KLPP 코알라 (APIO17_koala) C++14
37 / 100
94 ms 936 KB
#include "koala.h"
#include<vector>
#include<iostream>

using namespace std;
int minValue(int N, int W) {
	int arr[N];
	for(int i=0;i<N;i++)arr[i]=0;
	arr[0]=1;
	int R[N];
	playRound(arr,R);
	if(R[0]<2){
		return 0;
	}else{
		for(int i=0;i<N;i++){
			if(R[i]==0)return i;
		}
	}
    return 0;
}



int maxValue(int N, int W) {
	vector<int> v;
	for(int i=0;i<N;i++)v.push_back(i);
	while(v.size()>1){
		int d=N/v.size();
		d=min(d,13);
		int arr[N];
		for(int i=0;i<N;i++){
			arr[i]=0;
		}
		for(int i=0;i<v.size();i++){
			arr[v[i]]=d;
		}/*for(int i=0;i<N;i++)cout<<arr[i]<<" ";
		cout<<endl;*/
		int sol[N];
		playRound(arr,sol);
		vector<int> V;
		for(int i=0;i<N;i++){
			if(sol[i]>d)V.push_back(i);
		}
		v=V;
	}
	
    return v[0];
}
int compare(int x, int y,int N){
	int lo,hi;
	lo=0;
	hi=14;
	while(hi-lo>1){
		int n=N;
		int mid=(hi+lo)/2;
		int arr[n];
		for(int i=0;i<n;i++)arr[i]=0;
		arr[x]=mid;
		arr[y]=mid;
		int b[n];
		playRound(arr,b);
		
		
		if(b[x]>b[y])return x;
		if(b[y]>b[x])return y;
		if(b[x]==0)hi=mid;
		else lo=mid;
		
	}
    return 0;
}
int greaterValue(int N, int W) {
	int lo,hi;
	lo=0;
	hi=14;
	while(hi-lo>1){
		int n=N;
		int mid=(hi+lo)/2;
		int arr[n];
		for(int i=0;i<n;i++)arr[i]=0;
		arr[0]=mid;
		arr[1]=mid;
		int b[n];
		playRound(arr,b);
		
		
		if(b[0]>b[1])return 0;
		if(b[1]>b[0])return 1;
		if(b[0]==0)hi=mid;
		else lo=mid;
		
	}
    return 0;
}
vector<int> order(int x,int y,int n){
	if(x==y){
		vector<int> v;
		v.push_back(x+1);
		return v;
	}
	int mid=(x+y)/2;
	vector<int> v1=order(x,mid,n);
	vector<int> v2=order(mid+1,y,n);
	int p1=0;
	int p2=0;
	vector<int> ans;
	while(p1<v1.size()){
		while(p2<v2.size() && compare(v1[p1],v2[p2],n)==v1[p1]){
			ans.push_back(v2[p2]);
			p2++;
		}
		ans.push_back(v1[p1]);
		p1++;
	}
	return ans;
}
void allValues(int N, int W, int *P) {
    if (W == 2*N) {
	int n=N;
        int arr[n];
	for(int i=0;i<n;i++)arr[i]=-1;
	for(int i=0;i<14;i++){
		int b[n];
		int r[n];
		for(int j=0;j<n;j++){
			if(arr[j]==-1)b[i]=0;
			else b[i]=arr[i];
		}
	}
    } else {
	vector<int> v=order(0,N-1,N);
    }
}

Compilation message

koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:34:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<v.size();i++){
               ~^~~~~~~~~
koala.cpp: In function 'std::vector<int> order(int, int, int)':
koala.cpp:107:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(p1<v1.size()){
        ~~^~~~~~~~~~
koala.cpp:108:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(p2<v2.size() && compare(v1[p1],v2[p2],n)==v1[p1]){
         ~~^~~~~~~~~~
koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:123:7: warning: variable 'b' set but not used [-Wunused-but-set-variable]
   int b[n];
       ^
koala.cpp:124:7: warning: unused variable 'r' [-Wunused-variable]
   int r[n];
       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 248 KB Output is correct
2 Correct 7 ms 356 KB Output is correct
3 Correct 7 ms 448 KB Output is correct
4 Correct 8 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 540 KB Output is correct
2 Correct 21 ms 588 KB Output is correct
3 Correct 24 ms 696 KB Output is correct
4 Correct 19 ms 696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 780 KB Output is correct
2 Correct 72 ms 780 KB Output is correct
3 Correct 59 ms 836 KB Output is correct
4 Correct 75 ms 936 KB Output is correct
5 Correct 64 ms 936 KB Output is correct
6 Correct 79 ms 936 KB Output is correct
7 Correct 72 ms 936 KB Output is correct
8 Correct 71 ms 936 KB Output is correct
9 Correct 94 ms 936 KB Output is correct
10 Correct 62 ms 936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 936 KB Output isn't correct
2 Halted 0 ms 0 KB -