Submission #409254

# Submission time Handle Problem Language Result Execution time Memory
409254 2021-05-20T12:36:02 Z cheissmart Koala Game (APIO17_koala) C++14
37 / 100
65 ms 328 KB
#ifndef CHEISSMART
#include "koala.h"
#endif
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
    cerr << to_string(h);
    if(sizeof ...(t)) cerr << ", ";
    DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7;

int a[100], b[100];

int minValue(int N, int W) {
    for(int i = 0; i < N; i++)
        a[i] = 1;
    playRound(a, b);
    int k;
    for(int j = 0; j < N; j++)
        if(b[j] == 2)
            k = j;
    for(int i = 0; i < N; i++)
        a[i] = 0;
    a[k] = 1;
    playRound(a, b);
    for(int i = 0; i < N; i++)
        if(b[i] == 0)
            return i;
}

int maxValue(int N, int W) {
    set<int> s;
    for(int i = 0; i < N; i++)
        s.insert(i);
    while(s.size() > 1) {
        int x = s.size();
        for(int i = 0; i < N; i++) {
            if(s.count(i)) {
                a[i] = W / x;
            } else {
                a[i] = 0;
            }
        }
        s.clear();
        playRound(a, b);
        for(int i = 0; i < N; i++)
            if(b[i] == W / x + 1)
                s.insert(i);
    }
    return *s.begin();
}

bool is_0_min(int N, int W) {
    for(int i = 0; i < N; i++)
        a[i] = 0;
    a[0] = 1;
    playRound(a, b);
    return b[0] <= a[0];
}

int greaterValue(int N, int W) {
    int lb = 1, rb = min(10, W / 2);
    while(true) {
        if(lb > rb) {
            if(is_0_min(N, W)) return 1;
            else return 0;
        }
        for(int i = 0; i < N; i++)
            a[i] = 0;
        int mb = (lb + rb) / 2;
        debug(lb, mb, rb);
        a[0] = a[1] = mb;
        playRound(a, b);
        if(b[0] > a[0] && b[1] <= a[1])
            return 0;
        if(b[1] > a[1] && b[0] <= a[0])
            return 1;
        if(b[0] > a[0] && b[1] > a[1])
            lb = mb + 1;
        else
            rb = mb - 1;
    }
}

void allValues(int N, int W, int *P) {
    if (W == 2*N) {
        // TODO: Implement Subtask 4 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    } else {
        // TODO: Implement Subtask 5 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    }
}

Compilation message

koala.cpp: In function 'int minValue(int, int)':
koala.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
koala.cpp:47:10: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |     a[k] = 1;
      |     ~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 200 KB Output is correct
2 Correct 8 ms 200 KB Output is correct
3 Correct 8 ms 200 KB Output is correct
4 Correct 8 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 312 KB Output is correct
2 Correct 17 ms 316 KB Output is correct
3 Correct 17 ms 312 KB Output is correct
4 Correct 17 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 320 KB Output is correct
2 Correct 64 ms 312 KB Output is correct
3 Correct 59 ms 324 KB Output is correct
4 Correct 58 ms 320 KB Output is correct
5 Correct 59 ms 320 KB Output is correct
6 Correct 59 ms 328 KB Output is correct
7 Correct 61 ms 308 KB Output is correct
8 Correct 60 ms 320 KB Output is correct
9 Correct 65 ms 320 KB Output is correct
10 Correct 60 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Output isn't correct
2 Halted 0 ms 0 KB -