답안 #115440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
115440 2019-06-07T13:33:58 Z 김세빈(#2863) 코알라 (APIO17_koala) C++14
56 / 100
71 ms 660 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 D[111];
	int i;
	
	for(i=0; i<n; i++){
		D[i] = i;
	}
	
	sort(D, D + n, [&](int &a, int &b){
		return compare(n, a, b);
	});
	
	for(i=0; i<n; i++){
		P[D[i]] = i + 1;
	}
}

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;
       ~~^~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 13 ms 384 KB Output is correct
3 Correct 14 ms 384 KB Output is correct
4 Correct 13 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 384 KB Output is correct
2 Correct 71 ms 660 KB Output is correct
3 Correct 62 ms 416 KB Output is correct
4 Correct 63 ms 384 KB Output is correct
5 Correct 63 ms 504 KB Output is correct
6 Correct 63 ms 384 KB Output is correct
7 Correct 62 ms 384 KB Output is correct
8 Correct 65 ms 532 KB Output is correct
9 Correct 63 ms 384 KB Output is correct
10 Correct 62 ms 424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 31 ms 380 KB Output is partially correct
2 Partially correct 50 ms 384 KB Output is partially correct
3 Partially correct 44 ms 384 KB Output is partially correct
4 Partially correct 46 ms 376 KB Output is partially correct
5 Partially correct 65 ms 512 KB Output is partially correct
6 Partially correct 43 ms 420 KB Output is partially correct
7 Partially correct 44 ms 384 KB Output is partially correct
8 Partially correct 43 ms 384 KB Output is partially correct
9 Partially correct 43 ms 384 KB Output is partially correct
10 Partially correct 40 ms 384 KB Output is partially correct
11 Partially correct 42 ms 384 KB Output is partially correct
12 Partially correct 30 ms 384 KB Output is partially correct
13 Partially correct 43 ms 384 KB Output is partially correct
14 Partially correct 46 ms 384 KB Output is partially correct
15 Partially correct 45 ms 384 KB Output is partially correct
16 Partially correct 47 ms 384 KB Output is partially correct
17 Partially correct 47 ms 384 KB Output is partially correct
18 Partially correct 48 ms 384 KB Output is partially correct
19 Partially correct 55 ms 384 KB Output is partially correct
20 Partially correct 47 ms 392 KB Output is partially correct
21 Partially correct 43 ms 384 KB Output is partially correct
22 Partially correct 46 ms 364 KB Output is partially correct
23 Partially correct 35 ms 384 KB Output is partially correct
24 Partially correct 46 ms 392 KB Output is partially correct
25 Partially correct 43 ms 384 KB Output is partially correct
26 Partially correct 51 ms 388 KB Output is partially correct
27 Partially correct 45 ms 384 KB Output is partially correct
28 Partially correct 48 ms 384 KB Output is partially correct
29 Partially correct 43 ms 384 KB Output is partially correct
30 Partially correct 47 ms 384 KB Output is partially correct
31 Partially correct 51 ms 304 KB Output is partially correct
32 Partially correct 56 ms 380 KB Output is partially correct
33 Partially correct 46 ms 388 KB Output is partially correct
34 Partially correct 40 ms 388 KB Output is partially correct
35 Partially correct 46 ms 376 KB Output is partially correct
36 Partially correct 44 ms 384 KB Output is partially correct
37 Partially correct 44 ms 492 KB Output is partially correct
38 Partially correct 44 ms 384 KB Output is partially correct
39 Partially correct 48 ms 392 KB Output is partially correct
40 Partially correct 47 ms 388 KB Output is partially correct