Submission #256465

# Submission time Handle Problem Language Result Execution time Memory
256465 2020-08-02T17:52:28 Z maximath_1 Koala Game (APIO17_koala) C++11
47 / 100
127 ms 2300 KB
#include "koala.h"
#include <bits/stdc++.h>
using namespace std;
 
int a[105], b[105];
 
int minValue(int n, int w){
    for(int i = 1; i < n; i ++)
        a[i] = 0;
    a[0] = 1;
    playRound(a, b);
    for(int i = 0; i < n; i ++)
        if(a[i] >= b[i]) return i;
    return 0;
}
 
vector<int> large;
int maxValue(int n, int w){
    large.clear();
    for(int i = 0; i < n; i ++)
        large.push_back(i);
    for(; large.size() > 1;){
        for(int i = 0; i < n; i ++)
            a[i] = 0;
        int ct = w / large.size();
        for(int i : large)
            a[i] = ct;
 
        playRound(a, b);
 
        large.clear();
        for(int i = 0; i < n; i ++)
            if(b[i] > ct)
                large.push_back(i);
    }
    return large[0];
}
 
int n, w;
bool cmp(int x, int y){
    int lf = 1, rg = min(w / 2, 12);
    for(int md; lf <= rg;){
        md = (lf + rg) / 2;
        for(int i = 0; i < n; i ++)
            a[i] = 0;
        a[x] = a[y] = md;
        playRound(a, b);
        bool gt0 = b[x] > a[x];
        bool gt1 = b[y] > a[y];
        if(gt0 == gt1){
            if(gt1) lf = md + 1;
            else rg = md - 1;
        }else{
            if(gt1) return 1;
            else return 0;
        }
    }
    return 0;
}
 
int greaterValue(int N, int W){
    n = N, w = W;
    return cmp(0, 1);
}
 
int every[105];
 
void solve(int n, int w, vector<int> v, int l, int r){
    if(l > r) return;
    if(l == r) return void(every[v[0]] = l);
    int ct = min((int)sqrt(2 * l), min(w / (r - l + 1), 8));
 
    for(int i = 0; i < n; i ++)
        a[i] = 0;
    for(int i = l - 1; i < r; i ++)
        a[i] = ct;
    playRound(a, b);
    vector<int> lf, rg;
    for(int i : v){
        if(b[i] > ct) rg.push_back(i);
        else lf.push_back(i);
    }
 
    solve(n, w, lf, l, l + (int)lf.size() - 1);
    solve(n, w, rg, r - (int)rg.size() + 1, r);
}
 
void allValues(int N, int W, int *P){
    n = N, w = W;
    if(W == N * 2){
        //sub4
        vector<int> tmp(n);
        for(int i = 0; i < n; i ++)
            tmp[i] = i;
        stable_sort(tmp.begin(), tmp.end(), [&](int x, int y){
            for(int i = 0; i < n; i ++) a[i] = 0;
            a[x] = a[y] = n;
            playRound(a, b);
            return b[x] < b[y];
        });
        for(int i = 0; i < n; i ++){
            for(int j = 0; j < n; j ++)
                if(tmp[j] == i) P[i] = j + 1;
        }
    }else{
        //sub5
        vector<int> v(n);
        iota(v.begin(), v.end(), 0);
        solve(n, w, v, 1, n);
        for(int i = 0; i < n; i ++)
            P[i] = every[i];
    }
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 384 KB Output is correct
2 Correct 17 ms 384 KB Output is correct
3 Correct 17 ms 384 KB Output is correct
4 Correct 17 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 384 KB Output is correct
2 Correct 73 ms 384 KB Output is correct
3 Correct 62 ms 384 KB Output is correct
4 Correct 63 ms 384 KB Output is correct
5 Correct 64 ms 384 KB Output is correct
6 Correct 63 ms 384 KB Output is correct
7 Correct 63 ms 384 KB Output is correct
8 Correct 65 ms 384 KB Output is correct
9 Correct 62 ms 384 KB Output is correct
10 Correct 62 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 384 KB Output is correct
2 Correct 50 ms 384 KB Output is correct
3 Correct 48 ms 384 KB Output is correct
4 Correct 47 ms 384 KB Output is correct
5 Correct 47 ms 376 KB Output is correct
6 Correct 47 ms 376 KB Output is correct
7 Correct 49 ms 384 KB Output is correct
8 Correct 47 ms 384 KB Output is correct
9 Correct 48 ms 384 KB Output is correct
10 Correct 46 ms 376 KB Output is correct
11 Correct 49 ms 384 KB Output is correct
12 Correct 21 ms 384 KB Output is correct
13 Correct 45 ms 384 KB Output is correct
14 Correct 42 ms 376 KB Output is correct
15 Correct 47 ms 380 KB Output is correct
16 Correct 44 ms 376 KB Output is correct
17 Correct 43 ms 376 KB Output is correct
18 Correct 43 ms 384 KB Output is correct
19 Correct 44 ms 384 KB Output is correct
20 Correct 45 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 127 ms 2300 KB Output isn't correct
3 Halted 0 ms 0 KB -