Submission #745565

# Submission time Handle Problem Language Result Execution time Memory
745565 2023-05-20T11:38:01 Z grogu Koala Game (APIO17_koala) C++14
37 / 100
85 ms 1104 KB
#include "koala.h"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
using namespace std;

int B[100];
int R[100];
int minValue(int N, int W){
    B[0] = 1;
    for(int i=1;i<=99;i++){
        B[i] = 0;
    }
    playRound(B,R);
    for(int i=0;i<=99;i++){
        if(R[i]==0){
            return i;
        }
    }
    return 0;
}

int maxValue(int N, int W){
    vector<int> curr;
    for(int i=0;i<=99;i++){
        curr.push_back(i);
    }
    while(curr.size()>1){
        for(int i=0;i<=99;i++){
            B[i] = 0;
        }
        int cnt = 100/curr.size();
        for(int i:curr){
            B[i] = cnt;
        }
        playRound(B,R);
        vector<int> curr2;
        for(int i:curr){
            if(R[i]>B[i]){
                curr2.push_back(i);
            }
        }
        curr = curr2;
    }
    return curr[0];
}

int greaterValue(int N, int W){
    int low=0,high=6;
    vector<int> v = {1,2,3,4,5,6,8};
    while(1){
        int mid = (low+high)/2;
        for(int i=0;i<=99;i++){
            B[i] = 0;
        }
        B[0] = v[mid];
        B[1] = v[mid];
        playRound(B,R);
        if(R[0]>B[0] and R[1]>B[1]){
            low = mid+1;
        }
        else if(R[0]<=B[0] and R[1]<=B[1]){
            high = mid-1;
        }
        else if(R[0]>B[0]){
            return 0;
        }
        else{
            return 1;
        }
    }
    return 0;
}
void reshi(vector<ll> v,int n,int w,int *ans,int l,int r){
    if(l==r) ans[v[0]] = l;
    else{
        int c = (w-n+r)/(r-l+1)+1;
        c = min(c,r-1);
        c = min(c,w/(r-l+1));
        //dbg(c);
        for(ll i = 0;i<100;i++) B[i] = 0;
        for(ll x : v) B[x] = c;
        playRound(B,R);
        vector<ll> le,gr;
        for(ll x : v){
            if(R[x]>c) gr.pb(x);
            else le.pb(x);
        }
        reshi(le,n,w,ans,l,l+le.size()-1);
        reshi(gr,n,w,ans,r-gr.size()+1,r);

    }
}
void allValues(int N, int W, int *P) {
    vector<ll> v(N);
    iota(all(v),0);
    reshi(v,N,W,P,1,N);
    return;
}
/**
4 1
6 6
5 3 2 1 6 4
**/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 4 ms 320 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 5 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 252 KB Output is correct
2 Correct 11 ms 320 KB Output is correct
3 Correct 11 ms 208 KB Output is correct
4 Correct 12 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 336 KB Output is correct
2 Correct 71 ms 312 KB Output is correct
3 Correct 59 ms 324 KB Output is correct
4 Correct 59 ms 340 KB Output is correct
5 Correct 55 ms 336 KB Output is correct
6 Correct 76 ms 324 KB Output is correct
7 Correct 53 ms 328 KB Output is correct
8 Correct 61 ms 332 KB Output is correct
9 Correct 51 ms 320 KB Output is correct
10 Correct 53 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 1104 KB Output isn't correct
2 Halted 0 ms 0 KB -