Submission #1198959

#TimeUsernameProblemLanguageResultExecution timeMemory
1198959thieunguyenhuyKoala Game (APIO17_koala)C++17
Compilation error
0 ms0 KiB
#ifndef hwe
	#include "koala.h"
#endif

#include <bits/stdc++.h>
using namespace std;

#define popcount(n) (__builtin_popcountll((n)))
#define clz(n) (__builtin_clzll((n)))
#define ctz(n) (__builtin_ctzll((n)))
#define lg(n) (63 - __builtin_clzll((n)))
#define BIT(n, i) (((n) >> (i)) & 1ll)
#define MASK(i) (1ll << (i))
#define FLIP(n, i) ((n) ^ (1ll << (i)))
#define ON(n, i) ((n) | MASK(i))
#define OFF(n, i) ((n) & ~MASK(i))

#define Int __int128
#define fi first
#define se second

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long, long long>> vll;
typedef vector<pair<long long, int>> vli;
typedef vector<pair<int, long long>> vil;

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

template <class T>
void remove_duplicate(vector<T> &ve) {
    sort (ve.begin(), ve.end());
    ve.resize(unique(ve.begin(), ve.end()) - ve.begin());
}

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <class T> T random(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}
template <class T> T random(T r) {
    return rng() % r;
}

const int N = 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;

int B[N], R[N];

#ifdef hwe
namespace Jury {
    int dp[N][205], cnt[N][205];
    int perm[N];
    int W = 10;

    void test() {
        iota(perm, perm + N, 1);
        // shuffle(perm, perm + N, rng);
    }

    void playRound(int *B, int *R) {
        memset(dp, 0, sizeof dp);
        memset(cnt, 0, sizeof cnt);
        for (int i = 0; i < N; ++i) {
            // use B[i] + 1 get perm[i]
            if (i > 0) for (int j = 0; j <= W; ++j) dp[i][j] = dp[i - 1][j], cnt[i][j] = cnt[i - 1][j];
            for (int j = W; j >= B[i] + 1; --j) {
                maximize(dp[i][j], dp[i - 1][j - (B[i] + 1)] + perm[i]);
                if (dp[i][j] == dp[i - 1][j - (B[i] + 1)] + perm[i])
                    maximize(cnt[i][j], cnt[i - 1][j - (B[i] + 1)] + 1);
            }
        }

        for (int i = N - 1, j = W; i >= 0; --i) {
            if (dp[i][j] == dp[i - 1][j - (B[i] + 1)] + perm[i] && 
                cnt[i][j] == cnt[i - 1][j - (B[i] + 1)] + 1) {
                R[i] = B[i] + 1;
                j -= B[i] + 1;
            }
        }
    }
}
#endif

void playRound(int *B, int *R) {
    Jury::playRound(B, R);
}

vector<int> play(const vector<int> &veB) {
	for (int i = 0; i < veB.size(); ++i) B[i] = veB[i];
	playRound(B, R); vector<int> veR(veB.size());
	for (int i = 0; i < veB.size(); ++i) veR[i] = R[i];
	return veR;
}

int minValue(int n, int W) {
    // TODO: Implement Subtask 1 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
	vector<int> B(n, 0); B[0] = 1;
	vector<int> R = play(B);

	if (R[0] <= B[0]) return 0;
	for (int i = 1; i < n; ++i) if (R[i] == 0) {
		return i;
	}
	return -1;
}

int maxValue(int n, int W) {
    // TODO: Implement Subtask 2 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
	
    vector<int> candidates(n);
    iota(candidates.begin(), candidates.end(), 0);

    while (candidates.size() > 1) {
        cerr << candidates.size() << '\n';
        vector<int> B(n, 0);
        for (auto &x : candidates) B[x] = W / candidates.size();
        vector<int> R = play(B), new_candidates;
        for (auto &x : candidates) if (R[x] > B[x]) {
            new_candidates.emplace_back(x);
        }
        swap(candidates, new_candidates);
        // for (auto &x : candidates) cerr << x << ' ';
        // cerr << '\n';
    }

    return candidates[0];
}

int greaterValue(int n, int W) {
    // TODO: Implement Subtask 3 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    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.
    }
}

#ifdef hwe
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    Jury::test();
    cerr << maxValue(N, Jury::W) << '\n';

    cerr << '\n'; return 0;
}
#endif

Compilation message (stderr)

koala.cpp: In function 'void playRound(int*, int*)':
koala.cpp:108:5: error: 'Jury' has not been declared
  108 |     Jury::playRound(B, R);
      |     ^~~~