Submission #1262029

#TimeUsernameProblemLanguageResultExecution timeMemory
1262029Zbyszek99Koala Game (APIO17_koala)C++20
19 / 100
22 ms436 KiB
#include "koala.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll los(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;


int minValue(int N, int W) 
{
    int q[N];
    rep(i,N) q[i] = 0;
    q[0] = 1;
    int ans[N];
    playRound(q,ans);
    rep(i,N)
    {
        if(ans[i] <= q[i]) return i;
    }
}

int solve(int n, vi p)
{
    if(siz(p) == 1) return p[0];
    int k = 0;
    rep2(kk,1,n)
    {
        if(siz(p)*kk > n) break;
        int s1 = (n-siz(p))*(n-siz(p)+1)/2;
        int s2 = 0;
        rep2(i,n-siz(p)+1,n)
        {
            if(kk*(i-(n-siz(p))+1) <= n)
            {
                s2 = max(s2,i*(i+1)/2);
            }
        }
        if(s2 > s1)
        {
            k = kk;
        }
    }
    int q[n];
    int ans[n];
    rep(i,n) q[i] = 0;
    forall(it,p) q[it] = k;
    playRound(q,ans);
    vi p2;
    forall(it,p) if(ans[it] > q[it]) p2.pb(it);
    return solve(n,p2);
}

int maxValue(int N, int W) 
{
    vi p;
    rep(i,N) p.pb(i);
    return solve(N,p);
}

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;
}

bool comp(int a, int b)
{
    int q[100];
    int ans[100];
    rep(i,100) q[i] = 0;
    q[a] = 100;
    q[b] = 100;
    playRound(q,ans);
    if(ans[a] > 100) return 0;
    return 1;
}

void allValues(int N, int W, int *P) {
    if (W == 2*N) {
        vi p(N);
        rep(i,N) p.pb(i);
        sort(all(p),comp);
        rep(i,N)
        {
            P[p[i]] = i;
        }
    } 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 'int minValue(int, int)':
koala.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
#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...