Submission #745034

# Submission time Handle Problem Language Result Execution time Memory
745034 2023-05-19T10:25:53 Z Trunkty Koala Game (APIO17_koala) C++14
93 / 100
60 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(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){
            dosplit(x1,l,l+x1.size()-1);
            dosplit(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);
        }
        dosplit(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 3 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 208 KB Output is correct
2 Correct 12 ms 324 KB Output is correct
3 Correct 11 ms 316 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 328 KB Output is correct
2 Correct 60 ms 332 KB Output is correct
3 Correct 54 ms 328 KB Output is correct
4 Correct 58 ms 328 KB Output is correct
5 Correct 54 ms 328 KB Output is correct
6 Correct 57 ms 328 KB Output is correct
7 Correct 52 ms 336 KB Output is correct
8 Correct 53 ms 348 KB Output is correct
9 Correct 52 ms 444 KB Output is correct
10 Correct 54 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 208 KB Output is correct
2 Correct 9 ms 336 KB Output is correct
3 Correct 10 ms 328 KB Output is correct
4 Correct 10 ms 336 KB Output is correct
5 Correct 10 ms 320 KB Output is correct
6 Correct 10 ms 328 KB Output is correct
7 Correct 11 ms 328 KB Output is correct
8 Correct 10 ms 208 KB Output is correct
9 Correct 10 ms 324 KB Output is correct
10 Correct 9 ms 320 KB Output is correct
11 Correct 10 ms 336 KB Output is correct
12 Correct 9 ms 208 KB Output is correct
13 Correct 10 ms 208 KB Output is correct
14 Correct 10 ms 208 KB Output is correct
15 Correct 11 ms 328 KB Output is correct
16 Correct 10 ms 208 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 9 ms 208 KB Output is correct
19 Correct 11 ms 324 KB Output is correct
20 Correct 11 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 5 ms 208 KB Output is partially correct
2 Partially correct 5 ms 208 KB Output is partially correct
3 Partially correct 6 ms 208 KB Output is partially correct
4 Partially correct 6 ms 208 KB Output is partially correct
5 Partially correct 5 ms 208 KB Output is partially correct
6 Partially correct 6 ms 208 KB Output is partially correct
7 Partially correct 5 ms 208 KB Output is partially correct
8 Partially correct 5 ms 208 KB Output is partially correct
9 Partially correct 5 ms 208 KB Output is partially correct
10 Partially correct 5 ms 208 KB Output is partially correct
11 Partially correct 6 ms 208 KB Output is partially correct
12 Partially correct 4 ms 208 KB Output is partially correct
13 Partially correct 5 ms 208 KB Output is partially correct
14 Partially correct 5 ms 208 KB Output is partially correct
15 Partially correct 5 ms 208 KB Output is partially correct
16 Partially correct 5 ms 208 KB Output is partially correct
17 Partially correct 5 ms 208 KB Output is partially correct
18 Partially correct 6 ms 208 KB Output is partially correct
19 Partially correct 5 ms 320 KB Output is partially correct
20 Partially correct 6 ms 208 KB Output is partially correct
21 Partially correct 5 ms 324 KB Output is partially correct
22 Partially correct 5 ms 324 KB Output is partially correct
23 Partially correct 5 ms 336 KB Output is partially correct
24 Partially correct 5 ms 208 KB Output is partially correct
25 Partially correct 6 ms 208 KB Output is partially correct
26 Partially correct 6 ms 208 KB Output is partially correct
27 Partially correct 5 ms 208 KB Output is partially correct
28 Partially correct 6 ms 208 KB Output is partially correct
29 Partially correct 6 ms 324 KB Output is partially correct
30 Partially correct 5 ms 208 KB Output is partially correct
31 Partially correct 5 ms 324 KB Output is partially correct
32 Partially correct 5 ms 208 KB Output is partially correct
33 Partially correct 5 ms 208 KB Output is partially correct
34 Partially correct 5 ms 208 KB Output is partially correct
35 Partially correct 5 ms 324 KB Output is partially correct
36 Partially correct 5 ms 208 KB Output is partially correct
37 Partially correct 5 ms 208 KB Output is partially correct
38 Partially correct 4 ms 208 KB Output is partially correct
39 Partially correct 5 ms 208 KB Output is partially correct
40 Partially correct 5 ms 208 KB Output is partially correct