Submission #1165256

#TimeUsernameProblemLanguageResultExecution timeMemory
1165256steveonalexKoala Game (APIO17_koala)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll gcd(ll a, ll b){return __gcd(a, b);}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ull mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}

template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b) {a = b; return true;}
        return false;
    }

template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b) {a = b; return true;}
        return false;
    }

template <class T>
    void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){
        for(auto item: container) out << item << separator;
        out << finish;
    }

template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

#include "koala.h"


int minValue(int n, int w) {
    int a[n], b[n];
    memset(a, 0, sizeof a); memset(b, 0, sizeof b);
    a[0] = 1;

    playRound(a, b);
    if (b[0] < a[0]){
        return 0;
    }
    else{
        for(int i = 1; i < n; ++i) if (b[i] <= a[i]) return i;
    }
    assert(false);
    return 0;
}

int maxValue(int n, int w) {
    vector<int> S;
    for(int i = 0; i < n; ++i) S.push_back(i);


    for(int it = 0; it < 4; ++it){
        int a[n], b[n]; memset(a, 0, sizeof a); memset(b, 0, sizeof b);

        int dih = 100 / S.size();
        for(int i: S) a[i] = dih;

        playRound(a, b);

        vector<int> T;
        for(int i: S) if (b[i] > a[i]) T.push_back(i);
        S = T;
    }
    return S[0];
}

bool cmp1(int x, int y){
    if (x == y) return false;
    vector<int> blocked_cells;
    while(true){
        int a[n], b[n];
        memset(a, 0, sizeof a); memset(b, 0, sizeof b);

        a[x] = a[y] = blocked_cells.size() + 1;
        if (a[x] == 7) a[x] = a[y] = 8;
        int dih = 100 - 2 * (blocked_cells.size() + 1);
        for(int i: blocked_cells) a[i] = dih / blocked_cells.size();

        playRound(a, b);

        bool b1 = b[x] > a[x], b2 = b[y] > a[y];
        if (b1 && b2){
            for(int i = 0; i < n; ++i) if (i != x && i != y && b[i] <= a[i]) blocked_cells.push_back(i);
            remove_dup(blocked_cells);
        }
        else if (b1) return false;
        else return true;
    }
}

int greaterValue(int n, int w) {
    if (cmp(0, 1)) return 1;
    return 0;
}

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 (stderr)

koala.cpp: In function 'bool cmp1(int, int)':
koala.cpp:93:15: error: 'n' was not declared in this scope
   93 |         int a[n], b[n];
      |               ^
koala.cpp:94:16: error: 'a' was not declared in this scope
   94 |         memset(a, 0, sizeof a); memset(b, 0, sizeof b);
      |                ^
koala.cpp:94:40: error: 'b' was not declared in this scope
   94 |         memset(a, 0, sizeof a); memset(b, 0, sizeof b);
      |                                        ^
koala.cpp:104:19: error: 'b2' was not declared in this scope; did you mean 'b1'?
  104 |         if (b1 && b2){
      |                   ^~
      |                   b1
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:114:9: error: 'cmp' was not declared in this scope; did you mean 'cmp1'?
  114 |     if (cmp(0, 1)) return 1;
      |         ^~~
      |         cmp1