#include "koala.h"
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) x.size())
using namespace std;
int minValue(int N, int W) {
int B[N];
int R[N];
fill(B,B+N,0);
fill(R,R+N,0);
B[0] = 1;
playRound(B,R);
for(int i = 0;i < N;i++){
if(R[i] == 0) return i;
}
}
int maxValue(int N, int W) {
int B1[N], B2[N], B3[N], B4[N];
int R1[N], R2[N], R3[N], R4[N];
for(int i = 0;i < N;i++){
B1[i] = 1;
}
playRound(B1,R1);
for(int i = 0;i < N;i++){
B2[i] = R1[i];
}
playRound(B2,R2);
for(int i = 0;i < N;i++){
if(R2[i] == 3) B3[i] = 4;
else B3[i] = 0;
}
playRound(B3,R3);
for(int i = 0;i < N;i++){
if(R3[i] == 5) B4[i] = 11;
else B4[i] = 0;
}
playRound(B4,R4);
for(int i = 0;i < N;i++){
if(R4[i] == 12) return i;
}
return 0;
}
int comp(int N, int W, int a, int b) {
int B[N];
int R[N];
fill(B,B+N,0);
B[a] = 4; B[b] = 4;
playRound(B,R);
if(R[a] == 0 && R[b] > 0) return 1; ///something stands out
else if(R[a] > 0 && R[b] == 0) return 0; ///something stands out
else if(R[a] == 0 && R[b] == 0){
fill(B,B+N,0);
B[a] = 1; B[b] = 1;
playRound(B,R);
if(R[a] == 0) return 1;
if(R[b] == 0) return 0;
fill(B,B+N,0);
B[a] = 3;
B[b] = 3;
playRound(B,R);
if(R[a] == 0) return 1;
if(R[b] == 0) return 0;
}
fill(B,B+N,0);
B[a] = 7; B[b] = 7;
playRound(B,R);
if(R[a] == 0 && R[b] > 0) return 1; ///something stands out
else if(R[a] > 0 && R[b] == 0) return 0; ///something stands out
else if(R[a] == 0 && R[b] == 0){
fill(B,B+N,0);
B[a] = 5; B[b] = 5;
playRound(B,R);
if(R[a] == 0 && R[b] > 0) return 1; ///something stands out
else if(R[a] > 0 && R[b] == 0) return 0; ///something stands out
}
else{
fill(B,B+N,0);
B[a] = 10; B[b] = 10;
playRound(B,R);
if(R[a] == 0 && R[b] > 0) return 1; ///something stands out
else if(R[a] > 0 && R[b] == 0) return 0; ///something stands out
}
return 1;
}
int greaterValue(int N, int W){
return comp(N,W,0,1);
}
void allValues1(int n, int W, int *P){
int B[n]; int R[n]; int A[n];
for(int i = 0;i < n;i++) A[i] = i;
stable_sort(A, A+n, [&](int a, int b){
fill(B,B+n,0);
B[a] = n, B[b] = n;
playRound(B,R);
if(R[a] == 0) return true;
else return false;
});
for(int i = 0;i < n;i++) P[A[i]] = i+1;
}
int B[100]; int R[100];
vector<int> precompX = {1,1,1,1,1,1,1,1,1,2,1,1,2,3,3,1,3,1,1,2,3,4,2,3,4,4,1,2,3,3,4,1,5,1,2,2,3,5,3,4,5,2,5,2,3,4,5,4,4,6,1,2,3,5,6,3,4,6,5,6,1,4,5,6,1,7,1,2,2,2,3,4,5,7,3,4,7,5,6,7,2,5,6,7,2,2,3,4,5,6,8,3,4,6,8,5,8,6,8};
int ptr = 0;
void allValues2(int n, int *P, int s, int e, vector<int> stuff){
if(sz(stuff) == 1){
P[stuff[0]] = s;
return;
}
int X = precompX[ptr]; ptr++;
fill(B,B+n,0);
for(int i : stuff) B[i] = X;
playRound(B,R);
vector<int> left, right;
for(int i : stuff){
if(R[i] == 0) left.push_back(i);
else right.push_back(i);
}
int m = s + sz(left);
allValues2(n, P, s, m-1, left);
allValues2(n, P, m, e, right);
}
Compilation message
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
16 | }
| ^
/tmp/ccCwUZ8D.o: In function `runGame(int)':
grader.cpp:(.text+0x191): undefined reference to `allValues(int, int, int*)'
collect2: error: ld returned 1 exit status