## Submission #111796

# Submission time Handle Problem Language Result Execution time Memory
111796 2019-05-16T07:44:19 Z dndhk Koala Game (APIO17_koala) C++14
47 / 100
120 ms 496 KB
```#include "koala.h"
#include <algorithm>
#include <vector>

#define pb push_back

using namespace std;

int B[100], R[100];

int minValue(int N, int W) {
B[99] = 1;
playRound(B, R);
for(int i=0; i<N; i++){
if(R[i]==0){
return i;
}
}
return 99;
}

int maxValue(int N, int W) {
for(int i=0; i<N; i++){
B[i] = 1;
}
playRound(B, R);
for(int i=0; i<N; i++){
if(R[i]==2){
B[i] = 2;
}else{
B[i] = 0;
}
}
playRound(B, R);
int cnt = 25;
for(int i=0; i<N; i++){
if(R[i]>=3){
B[i] = 3;
}else if(B[i]!=0 && cnt>0){
B[i] = 1;
cnt--;
}else B[i] = 0;
}
playRound(B, R);
for(int i=0; i<N; i++){
if(R[i]>=4){
B[i] = 13;
}else   B[i] = 0;
}
playRound(B, R);
for(int i=0; i<N; i++){
if(R[i]>=14){
return i;
}
}
return -1;
}

int chk(int x){
B[0] = B[1] = x;
playRound(B, R);
if(R[0]>x && R[1]>x){
return 2;
}else if(R[0]<=x && R[1]<=x){
return 3;
}else{
if(R[0]>R[1])   return 0;
return 1;
}
}

int greaterValue(int N, int W) {
int t = chk(3);
if(t==0)    return 0;
if(t==1)    return 1;
if(t==2){
t = chk(5);
if(t==0)    return 0;
if(t==1)    return 1;
if(t==2){
t = chk(8);
if(t==0)    return 0;
return 1;
}
}else{
t = chk(2);
if(t==0)    return 0;
if(t==1)    return 1;
if(t==3){
t = chk(1);
if(t==0)    return 0;
return 1;
}
}
return -1;
}

int n;

bool sf(int x, int y){
B[x] = B[y] = 100;
playRound(B, R);
B[x] = B[y] = 0;
if(R[x]>R[y])   return 1;
return 0;
}

int arr[100];
vector<int> v;

void srt(int x, int y){
if(x==y)    return;
int m = (x+y)/2;
srt(x, m); srt(m+1, y);
int i1 = x, i2 = m+1;
while(!v.empty())   v.pop_back();
while(i1<=m || i2<=y){
if(i1>m){
v.pb(arr[i2++]);
}else if(i2>y){
v.pb(arr[i1++]);
}else{
bool t = sf(arr[i1], arr[i2]);
if(t){
v.pb(arr[i2++]);
}else{
v.pb(arr[i1++]);
}
}
}
for(int i=0; i<v.size(); i++){
arr[i+x] = v[i];
}
return;
}

void allValues(int N, int W, int *P) {
if (W == 2*N) {
n = N;
for(int i=0; i<N; i++){
arr[i] = i;
}
srt(0, N-1);
for(int i=0; i<N; i++){
P[arr[i]] = i+1;
}
} else {
// TODO: Implement Subtask 5 solution here.
// You may leave this block unmodified if you are not attempting this
}
}
```

### Compilation message

```koala.cpp: In function 'void srt(int, int)':
koala.cpp:131:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~```

#### Subtask #1 4.0 / 4.0

# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 8 ms 256 KB Output is correct
4 Correct 6 ms 376 KB Output is correct

#### Subtask #2 15.0 / 15.0

# Verdict Execution time Memory Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 36 ms 384 KB Output is correct
3 Correct 20 ms 256 KB Output is correct
4 Correct 13 ms 376 KB Output is correct

#### Subtask #3 18.0 / 18.0

# Verdict Execution time Memory Grader output
1 Correct 73 ms 376 KB Output is correct
2 Correct 71 ms 392 KB Output is correct
3 Correct 69 ms 376 KB Output is correct
4 Correct 74 ms 408 KB Output is correct
5 Correct 89 ms 376 KB Output is correct
6 Correct 88 ms 376 KB Output is correct
7 Correct 120 ms 376 KB Output is correct
8 Correct 86 ms 496 KB Output is correct
9 Correct 80 ms 428 KB Output is correct
10 Correct 94 ms 392 KB Output is correct

#### Subtask #4 10.0 / 10.0

# Verdict Execution time Memory Grader output
1 Correct 27 ms 256 KB Output is correct
2 Correct 48 ms 384 KB Output is correct
3 Correct 32 ms 384 KB Output is correct
4 Correct 38 ms 364 KB Output is correct
5 Correct 29 ms 364 KB Output is correct
6 Correct 39 ms 360 KB Output is correct
7 Correct 45 ms 380 KB Output is correct
8 Correct 29 ms 400 KB Output is correct
9 Correct 30 ms 384 KB Output is correct
10 Correct 29 ms 364 KB Output is correct
11 Correct 28 ms 372 KB Output is correct
12 Correct 17 ms 372 KB Output is correct
13 Correct 28 ms 384 KB Output is correct
14 Correct 27 ms 364 KB Output is correct
15 Correct 29 ms 384 KB Output is correct
16 Correct 27 ms 384 KB Output is correct
17 Correct 27 ms 400 KB Output is correct
18 Correct 32 ms 356 KB Output is correct
19 Correct 25 ms 256 KB Output is correct
20 Correct 42 ms 384 KB Output is correct

#### Subtask #5 0 / 53.0

# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -