Submission #115438

# Submission time Handle Problem Language Result Execution time Memory
115438 2019-06-07T13:32:39 Z 김세빈(#2863) Koala Game (APIO17_koala) C++14
37 / 100
73 ms 768 KB
#include <bits/stdc++.h>

#include "koala.h"

using namespace std;

int minValue(int n, int w)
{
	int B[111], R[111];
	int i;
	
	for(i=0; i<n; i++){
		B[i] = 1;
	}
	
	playRound(B, R);
	
	for(i=0; i<n; i++){
		if(R[i] == 2) break;
		B[i] = 0;
	}
	
	B[i] = 1;
	
	for(i++; i<n; i++){
		B[i] = 0;
	}
	
	playRound(B, R);
	
	for(i=0; i<n; i++){
		if(!R[i]) return i;
	}
	
    return 0;
}

int maxValue(int n, int w)
{
	int B[111], R[111];
	int i, s, k;
	
	for(i=0; i<n; i++){
		B[i] = 1;
	}
	
	for(k=1, s=n; s>1; ){
		for(i=0; i<n; i++){
			B[i] *= k;
		}
		
		playRound(B, R);
		
		for(i=0, s=0; i<n; i++){
			if(B[i] == k && R[i] > k){
				B[i] = 1; s ++;
			}
			else B[i] = 0;
		}
		
		k = n / s;
	}
	
	for(i=0; i<n; i++){
		if(B[i]) return i;
	}
	
	return 0;
}

bool compare(int n, int x, int y)
{
	int B[111], R[111];
	int N[6] = {1, 2, 3, 4, 6, 10};
	int i, s, e, m;
	
	for(s=0, e=5; s<=e; ){
		m = s + e >> 1;
		
		for(i=0; i<n; i++){
			B[i] = 0;
		}
		
		B[x] = B[y] = N[m];
		
		playRound(B, R);
		
		if(R[x] && R[y]) s = m + 1;
		else if(!R[x] && !R[y]) e = m - 1;
		else return !R[x];
	}
	
	return 0;
}

int greaterValue(int n, int w){ return compare(n, 0, 1); }

void allValues(int n, int w, int *P)
{
	int i;
	
	for(i=0; i<n; i++){
		P[i] = i;
	}
	
	sort(P, P + n, [&](int &a, int &b){
		return compare(n, a, b);
	});
}

Compilation message

koala.cpp: In function 'bool compare(int, int, int)':
koala.cpp:78:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   m = s + e >> 1;
       ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 13 ms 428 KB Output is correct
3 Correct 14 ms 384 KB Output is correct
4 Correct 13 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 384 KB Output is correct
2 Correct 73 ms 768 KB Output is correct
3 Correct 63 ms 768 KB Output is correct
4 Correct 63 ms 760 KB Output is correct
5 Correct 64 ms 748 KB Output is correct
6 Correct 64 ms 768 KB Output is correct
7 Correct 63 ms 768 KB Output is correct
8 Correct 64 ms 760 KB Output is correct
9 Correct 63 ms 764 KB Output is correct
10 Correct 62 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -