답안 #234398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
234398 2020-05-24T06:59:12 Z rama_pang 코알라 (APIO17_koala) C++14
74 / 100
56 ms 512 KB
#include "koala.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100;

int B[MAXN], R[MAXN];

void Reset() {
  for (int i = 0; i < MAXN; i++) {
    B[i] = R[i] = 0;
  }
}

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

int maxValue(int N, int W) {
  vector<int> large(N);
  iota(begin(large), end(large), 0);
  while (large.size() > 1) {
    int k = min(9, W / (int) large.size());
    Reset();
    for (auto i : large) {
      B[i] = k;
    }
    playRound(B, R);
    large.clear();
    for (int i = 0; i < N; i++) {
      if (R[i] > k) {
        large.emplace_back(i);
      }
    }
  }
  return large[0];
}

int greaterValue(int N, int W) {
  int lo = 1, hi = 9;
  while (lo <= hi) {
    int k = (lo + hi) / 2;
    Reset();
    B[0] = B[1] = k;
    playRound(B, R);
    if (R[0] <= k && R[1] <= k) {
      lo = k + 1;
    } else if (R[0] > k && R[1] > k) {
      hi = k - 1;
    } else {
      return R[0] < R[1];
    }
  }
  return -1;
}

void Solve(int N, int W, int *P, vector<int> v, int l, int r) {
  if (l > r) return;
  if (l == r) return void(P[v[0]] = l);
  int k = min({(int) sqrt(2 * l), W / (r - l + 1), 8});
  
  Reset();
  for (auto i : v) {
    B[i] = k;
  }
  playRound(B, R);

  vector<int> ls, gr;
  for (auto i : v) {
    if (R[i] > k) {
      gr.emplace_back(i);
    } else {
      ls.emplace_back(i);
    }
  }

  Solve(N, W, P, ls, l, l + int(ls.size()) - 1);
  Solve(N, W, P, gr, r - int(gr.size()) + 1, r);
}

void allValues(int N, int W, int *P) {
  if (W == 2 * N) {
    vector<int> v(N);
    iota(begin(v), end(v), 0);
    stable_sort(begin(v), end(v), [&](int a, int b) { 
      Reset();
      B[a] = B[b] = N;
      playRound(B, R);
      return R[a] < R[b];
    });
    for (int i = 0; i < N; i++) {
      P[v[i]] = i + 1;
    }
  } else {
    vector<int> v(N);
    iota(begin(v), end(v), 0);
    return Solve(N, W, P, v, 1, N);
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 25 ms 512 KB Output is partially correct
2 Partially correct 26 ms 384 KB Output is partially correct
3 Partially correct 26 ms 384 KB Output is partially correct
4 Partially correct 25 ms 384 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 384 KB Output is correct
2 Correct 54 ms 384 KB Output is correct
3 Correct 54 ms 384 KB Output is correct
4 Correct 51 ms 384 KB Output is correct
5 Correct 51 ms 384 KB Output is correct
6 Correct 51 ms 384 KB Output is correct
7 Correct 53 ms 376 KB Output is correct
8 Correct 52 ms 384 KB Output is correct
9 Correct 56 ms 384 KB Output is correct
10 Correct 50 ms 384 KB Output is correct
11 Correct 54 ms 464 KB Output is correct
12 Correct 24 ms 384 KB Output is correct
13 Correct 51 ms 376 KB Output is correct
14 Correct 46 ms 384 KB Output is correct
15 Correct 46 ms 384 KB Output is correct
16 Correct 53 ms 384 KB Output is correct
17 Correct 46 ms 380 KB Output is correct
18 Correct 47 ms 384 KB Output is correct
19 Correct 48 ms 384 KB Output is correct
20 Correct 48 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 8 ms 384 KB Output is correct
8 Correct 9 ms 384 KB Output is correct
9 Correct 8 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 8 ms 384 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 8 ms 384 KB Output is correct
14 Correct 8 ms 384 KB Output is correct
15 Correct 8 ms 384 KB Output is correct
16 Correct 8 ms 384 KB Output is correct
17 Correct 8 ms 384 KB Output is correct
18 Correct 9 ms 384 KB Output is correct
19 Correct 8 ms 384 KB Output is correct
20 Correct 8 ms 384 KB Output is correct
21 Correct 8 ms 384 KB Output is correct
22 Correct 8 ms 384 KB Output is correct
23 Correct 9 ms 384 KB Output is correct
24 Correct 9 ms 384 KB Output is correct
25 Correct 8 ms 384 KB Output is correct
26 Correct 8 ms 384 KB Output is correct
27 Correct 8 ms 384 KB Output is correct
28 Correct 8 ms 384 KB Output is correct
29 Correct 9 ms 384 KB Output is correct
30 Correct 8 ms 384 KB Output is correct
31 Correct 8 ms 384 KB Output is correct
32 Correct 8 ms 384 KB Output is correct
33 Correct 8 ms 384 KB Output is correct
34 Correct 9 ms 384 KB Output is correct
35 Correct 8 ms 384 KB Output is correct
36 Correct 8 ms 384 KB Output is correct
37 Correct 10 ms 384 KB Output is correct
38 Correct 8 ms 384 KB Output is correct
39 Correct 8 ms 384 KB Output is correct
40 Correct 8 ms 384 KB Output is correct