제출 #1342417

#제출 시각아이디문제언어결과실행 시간메모리
1342417javkhlantogs코알라 (APIO17_koala)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
#include "koala.h"
#define ll long long
using namespace std;
int i,j,k,q;
int b[100],r[100];
int minValue(int n,int w){
	for(i=0 ; i<n ; i++) b[i]=0;
	b[0]=1;
	playRound(b,r);
	for(i=0 ; i<n ; i++){
		if(r[i]<=b[i]) return i;
	}
}
int maxValue(int n,int w){
	for(i=0 ; i<n ; i++) b[i]=1;
	playRound(b,r);
	while(1){
		ll cnt=0;
		for(i=0 ; i<n ; i++) if(r[i]>b[i] and b[i]!=0) cnt++; 
		if(cnt==1) for(i=0 ; i<n ; i++) if(r[i]>b[i] and b[i]!=0) return i;
		for(i=0 ; i<n ; i++){
			if(r[i]>b[i] and b[i]!=0) b[i]=100/cnt;
				else b[i]=0;
		}
		playRound(b,r);
	}
}
int greaterValue(int n,int w){
	int ok=0,ng=10;
	for(i=0 ; i<n ; i++) b[i]=0;
	while(ng-ok>1){
		int mid=(ng+ok)/2;
		b[0]=b[1]=mid;
		playRound(b,r);
		if(r[1]<=b[1] and r[0]<=b[0]) ng=mid;
			else if(r[0]>b[0] and r[1]>b[1]) ok=mid;
				else{
					if(r[0]<r[1]) return 1;
						else return 0;
				}
	}
}
bool check(int i,int j){
	for(k=0 ; k<n ; k++) b[k]=0;
	b[a[i]]=b[a[j]]=100;
	playRound(b,r);
	if(r[a[i]]>r[a[j]]) return 1;
	return 0;
}
void allValues(int n,int w,int *p){
	int a[n];
	for(i=0 ; i<n ; i++) a[i]=i;
	sort(a.begin(),a.end(),check);
	for(i=0 ; i<n ; i++) p[a[i]]=i+1;
}

컴파일 시 표준 에러 (stderr) 메시지

koala.cpp: In function 'bool check(int, int)':
koala.cpp:45:21: error: 'n' was not declared in this scope
   45 |         for(k=0 ; k<n ; k++) b[k]=0;
      |                     ^
koala.cpp:46:11: error: 'a' was not declared in this scope
   46 |         b[a[i]]=b[a[j]]=100;
      |           ^
koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:54:16: error: request for member 'begin' in 'a', which is of non-class type 'int [n]'
   54 |         sort(a.begin(),a.end(),check);
      |                ^~~~~
koala.cpp:54:26: error: request for member 'end' in 'a', which is of non-class type 'int [n]'
   54 |         sort(a.begin(),a.end(),check);
      |                          ^~~
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:14:1: warning: control reaches end of non-void function [-Wreturn-type]
   14 | }
      | ^
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^