Submission #745056

# Submission time Handle Problem Language Result Execution time Memory
745056 2023-05-19T10:49:00 Z Trunkty Koala Game (APIO17_koala) C++14
100 / 100
65 ms 444 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll

#include "koala.h"

int B[100],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;
}

int n,w;
int arr[100];

void dosplit(vector<int> x, int l, int r){
    if(l==1 and r==2){
        for(int i=0;i<=n-1;i++){
            B[i] = 0;
        }
        B[x[0]] = 1;
        playRound(B,R);
        if(R[x[0]]>B[x[0]]){
            arr[x[0]] = 2;
            arr[x[1]] = 1;
        }
        else{
            arr[x[1]] = 2;
            arr[x[0]] = 1;
        }
        return;
    }
    if(x.size()==1){
        arr[x[0]] = l;
        return;
    }
    int val=1;
    for(int i=2;i<=1e9;i++){
        int curr = r+1-i*(r-l+1);
        int tot=0;
        for(int j=l-curr-1;j>=l-curr-i;j--){
            tot += j;
        }
        if(tot>l){
            val = i-1;
            break;
        }
    }
    for(int i=0;i<=n-1;i++){
        B[i] = 0;
    }
    for(int i:x){
        B[i] = val;
    }
    playRound(B,R);
    vector<int> x1,x2;
    for(int i:x){
        if(R[i]>B[i]){
            x2.push_back(i);
        }
        else{
            x1.push_back(i);
        }
    }
    dosplit(x1,l,l+x1.size()-1);
    dosplit(x2,r-x2.size()+1,r);
}

void dosplit2(vector<int> x, int l, int r){
    if(x.size()==1){
        arr[x[0]] = l;
        return;
    }
    int low=1,high=w/(r-l+1);
    while(1){
        int mid=(low+high)/2;
        for(int i=0;i<=n-1;i++){
            B[i] = 0;
        }
        for(int i:x){
            B[i] = mid;
        }
        playRound(B,R);
        vector<int> x1,x2;
        for(int i:x){
            if(R[i]>B[i]){
                x2.push_back(i);
            }
            else{
                x1.push_back(i);
            }
        }
        if(x1.size()>0 and x2.size()>0){
            dosplit2(x1,l,l+x1.size()-1);
            dosplit2(x2,r-x2.size()+1,r);
            break;
        }
        else if(x1.size()>0){
            high = mid-1;
        }
        else{
            low = mid+1;
        }
    }
}

void allValues(int N, int W, int *P){
    n = N;
    w = W;
    if(W==2*N){
        vector<int> v;
        for(int i=0;i<N;i++){
            v.push_back(i);
        }
        dosplit2(v,1,N);
        for(int i=0;i<N;i++){
            P[i] = arr[i];
        }
    } 
    else{
        vector<int> v;
        for(int i=0;i<N;i++){
            v.push_back(i);
        }
        dosplit(v,1,N);
        for(int i=0;i<N;i++){
            P[i] = arr[i];
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 208 KB Output is correct
2 Correct 13 ms 324 KB Output is correct
3 Correct 13 ms 320 KB Output is correct
4 Correct 12 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 316 KB Output is correct
2 Correct 65 ms 316 KB Output is correct
3 Correct 55 ms 336 KB Output is correct
4 Correct 54 ms 336 KB Output is correct
5 Correct 57 ms 332 KB Output is correct
6 Correct 56 ms 320 KB Output is correct
7 Correct 65 ms 360 KB Output is correct
8 Correct 64 ms 336 KB Output is correct
9 Correct 58 ms 444 KB Output is correct
10 Correct 52 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 208 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Correct 12 ms 328 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 12 ms 336 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 9 ms 336 KB Output is correct
8 Correct 10 ms 324 KB Output is correct
9 Correct 10 ms 208 KB Output is correct
10 Correct 10 ms 324 KB Output is correct
11 Correct 11 ms 324 KB Output is correct
12 Correct 11 ms 336 KB Output is correct
13 Correct 11 ms 208 KB Output is correct
14 Correct 9 ms 208 KB Output is correct
15 Correct 10 ms 336 KB Output is correct
16 Correct 10 ms 320 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 10 ms 328 KB Output is correct
19 Correct 10 ms 336 KB Output is correct
20 Correct 11 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 3 ms 208 KB Output is correct
9 Correct 3 ms 208 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 3 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 208 KB Output is correct
16 Correct 3 ms 208 KB Output is correct
17 Correct 5 ms 320 KB Output is correct
18 Correct 3 ms 320 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 4 ms 208 KB Output is correct
23 Correct 3 ms 208 KB Output is correct
24 Correct 4 ms 208 KB Output is correct
25 Correct 3 ms 208 KB Output is correct
26 Correct 3 ms 208 KB Output is correct
27 Correct 3 ms 316 KB Output is correct
28 Correct 3 ms 324 KB Output is correct
29 Correct 3 ms 208 KB Output is correct
30 Correct 3 ms 316 KB Output is correct
31 Correct 3 ms 208 KB Output is correct
32 Correct 3 ms 320 KB Output is correct
33 Correct 3 ms 208 KB Output is correct
34 Correct 3 ms 208 KB Output is correct
35 Correct 3 ms 208 KB Output is correct
36 Correct 3 ms 208 KB Output is correct
37 Correct 3 ms 208 KB Output is correct
38 Correct 3 ms 208 KB Output is correct
39 Correct 3 ms 208 KB Output is correct
40 Correct 3 ms 208 KB Output is correct