답안 #392357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
392357 2021-04-20T20:39:42 Z MarcoMeijer 코알라 (APIO17_koala) C++14
47 / 100
136 ms 1060 KB
#include "koala.h"
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MX=500;

int B[MX], R[MX];

int minValue(int N, int W) {
    RE(i,N) B[i] = 0;
    B[1] = 1;
    playRound(B,R);
    RE(i,N) if(R[i] == 0) return i;
    return 0;
}

int maxValue(int N, int W) {
    vi possible;
    RE(i,N) possible.push_back(i);
    while(possible.size() > 1) {
        int weight = W / possible.size();
        RE(i,N) B[i] = 0;
        FOR(u,possible) B[u] = weight;
        playRound(B,R);
        possible.clear();
        RE(i,N) if(R[i] > weight) possible.push_back(i);
    }
    return possible[0];
}

int greaterValue(int N, int W, int i, int j) {
    int lb=1, ub=10;
    while(lb != ub) {
        int mid=(lb+ub)/2;
        RE(i,N) B[i] = 0;
        B[i] = mid;
        B[j] = mid;
        playRound(B,R);
        if(R[i] <= mid && R[j] <= mid) ub=mid-1;
        if(R[i] >  mid && R[j] >  mid) lb=mid+1;
        if(R[i] <= mid && R[j] >  mid) return j;
        if(R[i] >  mid && R[j] <= mid) return i;
    }
    RE(i,N) B[i] = 0;
    B[i] = lb;
    B[j] = lb;
    playRound(B,R);
    if(R[i] <= lb && R[j] > lb) return j;
    if(R[i] > lb && R[j] <= lb) return i;
    return i;
}

int greaterValue(int N, int W) {
    return greaterValue(N,W,0,1);
}

void findValues(int N, int W, int lb, int ub, vi f, int *P) {
    if(f.size() == 1) {
        P[f[0]] = lb;
        return;
    }

    int weight = (W - (N - ub) - 1) / f.size();
    if(weight == 0) weight = 1;
    if(W == N*2) weight = W / f.size();
    RE(i,N) B[i] = 0;
    FOR(u,f) B[u] = weight;
    playRound(B,R);

    vi left;
    vi right;
    FOR(u,f) (R[u] > weight ? right : left).push_back(u);
    findValues(N,W,lb,lb+left.size()-1,left,P);
    findValues(N,W,ub-right.size()+1,ub,right,P);
}

void allValues(int N, int W, int *P) {
    vi f;
    RE(i,N) f.push_back(i);
    findValues(N,W,1,N,f,P);
    if (W == 2*N) {
    } else {
        // TODO: Implement Subtask 5 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 200 KB Output is correct
2 Correct 5 ms 200 KB Output is correct
3 Correct 6 ms 200 KB Output is correct
4 Correct 5 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 200 KB Output is correct
2 Correct 18 ms 324 KB Output is correct
3 Correct 18 ms 320 KB Output is correct
4 Correct 17 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 324 KB Output is correct
2 Correct 78 ms 328 KB Output is correct
3 Correct 77 ms 452 KB Output is correct
4 Correct 81 ms 332 KB Output is correct
5 Correct 69 ms 332 KB Output is correct
6 Correct 71 ms 324 KB Output is correct
7 Correct 70 ms 328 KB Output is correct
8 Correct 72 ms 328 KB Output is correct
9 Correct 72 ms 448 KB Output is correct
10 Correct 76 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 200 KB Output is correct
2 Correct 10 ms 200 KB Output is correct
3 Correct 9 ms 312 KB Output is correct
4 Correct 8 ms 200 KB Output is correct
5 Correct 8 ms 200 KB Output is correct
6 Correct 8 ms 320 KB Output is correct
7 Correct 8 ms 200 KB Output is correct
8 Correct 9 ms 320 KB Output is correct
9 Correct 8 ms 328 KB Output is correct
10 Correct 8 ms 328 KB Output is correct
11 Correct 9 ms 324 KB Output is correct
12 Correct 8 ms 328 KB Output is correct
13 Correct 8 ms 328 KB Output is correct
14 Correct 8 ms 200 KB Output is correct
15 Correct 9 ms 200 KB Output is correct
16 Correct 8 ms 200 KB Output is correct
17 Correct 8 ms 324 KB Output is correct
18 Correct 8 ms 328 KB Output is correct
19 Correct 9 ms 328 KB Output is correct
20 Correct 8 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 136 ms 1060 KB Output isn't correct
2 Halted 0 ms 0 KB -