답안 #628279

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
628279 2022-08-13T09:31:04 Z I_love_Hoang_Yen 드문 곤충 (IOI22_insects) C++17
100 / 100
61 ms 348 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

int min_cardinality(int N) {
  int colors = 0;
  vector <int> insects;
  vector <int> order(N);
  iota(order.begin(),order.end(),0);
  
  mt19937 mt(715082022);
  shuffle(order.begin(),order.end(),mt);
  for (int x : order) {
    move_inside(x);
    if (press_button() == 1) {
      colors++;
    }
    else {
      move_outside(x);
      insects.push_back(x);
    }
  }
  
  int ans = 1;
  int rest = N - colors;
  vector <int> in, out;
  
  while (rest >= colors) {
    int mid = ans + (rest + colors + 1) / (2 * colors);
    
    shuffle(in.begin(),in.end(),mt);
    while ((int)in.size() > mid - ans) {
      int x = in.back();
      in.pop_back();
      insects.push_back(x);
      move_outside(x);
      
      if ((int)in.size() % colors == 0) {
        if (press_button() <= mid) {
          break;
        }
      }
    }
    
    shuffle(insects.begin(),insects.end(),mt);
    for (int x : insects) {
      if ((int)in.size() == colors * (mid - ans)) {
        out.push_back(x);
        continue;
      }
      move_inside(x);
      if ((int)in.size() >= mid - ans && press_button() > mid) {
        move_outside(x);
        out.push_back(x);
      }
      else {
        in.push_back(x);
      }
    }
    
    if ((int)in.size() == colors * (mid - ans)) {
      ans = mid;
      rest = out.size();
      insects = out;
      in.clear();
      out.clear();
    }
    else {
      rest = in.size();
      out.clear();
      insects.clear();
    }
  }
  
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 3 ms 208 KB Output is correct
9 Correct 4 ms 304 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 6 ms 304 KB Output is correct
13 Correct 6 ms 208 KB Output is correct
14 Correct 7 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 3 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 7 ms 208 KB Output is correct
19 Correct 6 ms 208 KB Output is correct
20 Correct 5 ms 208 KB Output is correct
21 Correct 4 ms 300 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 3 ms 208 KB Output is correct
9 Correct 4 ms 304 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 6 ms 304 KB Output is correct
13 Correct 6 ms 208 KB Output is correct
14 Correct 7 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 3 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 7 ms 208 KB Output is correct
19 Correct 6 ms 208 KB Output is correct
20 Correct 5 ms 208 KB Output is correct
21 Correct 4 ms 300 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
23 Correct 12 ms 308 KB Output is correct
24 Correct 9 ms 208 KB Output is correct
25 Correct 28 ms 292 KB Output is correct
26 Correct 27 ms 296 KB Output is correct
27 Correct 25 ms 308 KB Output is correct
28 Correct 5 ms 208 KB Output is correct
29 Correct 19 ms 308 KB Output is correct
30 Correct 31 ms 312 KB Output is correct
31 Correct 19 ms 296 KB Output is correct
32 Correct 23 ms 292 KB Output is correct
33 Correct 28 ms 312 KB Output is correct
34 Correct 20 ms 312 KB Output is correct
35 Correct 28 ms 208 KB Output is correct
36 Correct 31 ms 308 KB Output is correct
37 Correct 31 ms 296 KB Output is correct
38 Correct 20 ms 308 KB Output is correct
39 Correct 22 ms 304 KB Output is correct
40 Correct 15 ms 304 KB Output is correct
41 Correct 11 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 276 KB Output is correct
7 Correct 22 ms 312 KB Output is correct
8 Correct 19 ms 208 KB Output is correct
9 Correct 55 ms 308 KB Output is correct
10 Correct 44 ms 312 KB Output is correct
11 Correct 34 ms 312 KB Output is correct
12 Correct 25 ms 308 KB Output is correct
13 Correct 23 ms 312 KB Output is correct
14 Correct 52 ms 312 KB Output is correct
15 Correct 35 ms 308 KB Output is correct
16 Correct 38 ms 312 KB Output is correct
17 Correct 20 ms 316 KB Output is correct
18 Correct 47 ms 312 KB Output is correct
19 Correct 21 ms 312 KB Output is correct
20 Correct 24 ms 320 KB Output is correct
21 Correct 48 ms 320 KB Output is correct
22 Correct 35 ms 328 KB Output is correct
23 Correct 43 ms 324 KB Output is correct
24 Correct 43 ms 320 KB Output is correct
25 Correct 32 ms 304 KB Output is correct
26 Correct 17 ms 208 KB Output is correct
27 Correct 29 ms 312 KB Output is correct
28 Correct 44 ms 312 KB Output is correct
29 Correct 31 ms 312 KB Output is correct
30 Correct 23 ms 312 KB Output is correct
31 Correct 61 ms 308 KB Output is correct
32 Correct 25 ms 320 KB Output is correct
33 Correct 59 ms 312 KB Output is correct
34 Correct 45 ms 316 KB Output is correct
35 Correct 23 ms 348 KB Output is correct
36 Correct 48 ms 308 KB Output is correct
37 Correct 36 ms 308 KB Output is correct
38 Correct 55 ms 308 KB Output is correct
39 Correct 54 ms 316 KB Output is correct
40 Correct 47 ms 312 KB Output is correct
41 Correct 45 ms 316 KB Output is correct
42 Correct 36 ms 312 KB Output is correct
43 Correct 12 ms 304 KB Output is correct
44 Correct 38 ms 308 KB Output is correct
45 Correct 26 ms 312 KB Output is correct
46 Correct 26 ms 308 KB Output is correct
47 Correct 14 ms 208 KB Output is correct
48 Correct 20 ms 304 KB Output is correct