Submission #1165259

#TimeUsernameProblemLanguageResultExecution timeMemory
1165259steveonalexKoala Game (APIO17_koala)C++20
53 / 100
55 ms464 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){
    const int n = 100;
    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 (cmp1(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 {
        vector<int> perm(n);
        for(int i = 0; i < n; ++i) perm[i] = i;

        sort(ALL(perm), cmp1);

        for(int i = 0; i < n; ++i) P[perm[i]] = i + 1;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...