Submission #108361

# Submission time Handle Problem Language Result Execution time Memory
108361 2019-04-28T17:56:06 Z RezwanArefin01 Koala Game (APIO17_koala) C++17
37 / 100
90 ms 504 KB
#include <bits/stdc++.h>
#include "koala.h"
using namespace std; 

int B[100], R[100]; 

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

int maxValue(int N, int W) {
    vector<int> L; 
    for(int i = 0; i < N; ++i)
        L.push_back(i); 
    while(L.size() > 1) {
        int t = W / L.size(); 
        for(int i = 0; i < N; ++i) 
            B[i] = R[i] = 0; 
        for(int i : L) B[i] = t; 
        playRound(B, R); 
        L.clear(); 
        for(int i = 0; i < N; ++i) {
            if(R[i] > t) {
                L.push_back(i); 
            }
        }
    }
    return L[0];
}

int greaterValue(int N, int W) {
    int lo = 1, hi = min(W / 2, 9); 
    while(lo <= hi) {
        int mid = lo + hi >> 1; 
        B[0] = B[1] = mid; 
        playRound(B, R); 
        bool z = R[0] > B[0]; 
        bool o = R[1] > B[1]; 
        if(z == o) {
            if(z) lo = mid + 1; 
            else hi = mid - 1; 
        } else {
            return z ? 0 : 1; 
        }
    } return -1; 
}

void allValues(int N, int W, int *P) {
    int Q[N]; 
    for(int i = 0; i < N; ++i) Q[i] = i; 
    sort(Q, Q + N, [&W](int i, int j) {
        memset(B, 0, sizeof B); 
        B[i] = B[j] = W / 2;  
        playRound(B, R); 
        return R[i] < R[j];
    }); 
    for(int i = 0; i < N; ++i) P[Q[i]] = i + 1; 
}

Compilation message

koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:38:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid = lo + hi >> 1; 
                   ~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 384 KB Output is correct
2 Correct 13 ms 384 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 16 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 384 KB Output is correct
2 Correct 86 ms 384 KB Output is correct
3 Correct 72 ms 504 KB Output is correct
4 Correct 62 ms 416 KB Output is correct
5 Correct 68 ms 424 KB Output is correct
6 Correct 90 ms 384 KB Output is correct
7 Correct 50 ms 384 KB Output is correct
8 Correct 64 ms 380 KB Output is correct
9 Correct 55 ms 384 KB Output is correct
10 Correct 88 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 376 KB Output is correct
2 Incorrect 36 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -