답안 #926862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926862 2024-02-14T01:10:08 Z beaboss 드문 곤충 (IOI22_insects) C++17
52.93 / 100
120 ms 1592 KB
// Source: https://oj.uz/problem/view/IOI22_insects
// 
#include "insects.h"
#include "bits/stdc++.h"

using namespace std;

#define s second
#define f first
#define pb push_back

typedef long long ll;

typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef vector<int> vi;

#define FOR(i, a, b) for (int i = (a); i<b; i++)

bool ckmin(int& a, int b){ return b < a ? a = b, true : false; }

bool ckmax(int& a, int b){ return b > a ? a = b, true : false; }

set<int> in, out;

void gout(int i) {
  in.erase(i);
  out.insert(i);
  move_outside(i);
}

void gin(int i) {
  out.erase(i);
  in.insert(i);
  move_inside(i);
}

int min_cardinality(int n) {

  // cout << n << endl;
  FOR(i, 0, n) out.insert(i);

  int d = n;
  FOR(i, 0, n) {
    gin(i);
    if (press_button() > 1) {
      gout(i);
      d--;
    }
  }

  set<int> oth = in;
  for (auto val: oth) {
    gout(val);

  }

  if (d == 1) {
    return n;
  }

  int alr = 0;
  // cout << 'd' << endl;
  int prv = -1;
  int lo  = 1;
  int hi = n / 2;
  while (lo < hi) {
    int t = (lo + hi + 1) / (2);
    prv = out.size();
    // cout << out.size() << t << endl;
    // for (auto val: out) {
    //   cout << val << ' ';
    // }
    // cout << endl;
    // testing t
    set<int> oth = out;
    for (auto val: oth) {
      gin(val);
      if (press_button() > t) {
        gout(val);
      }
    }
    // cout << press_button() << endl;
    if (in.size() == t * d) { // all here --- erase this section
      // alr += t;
      // for (auto it = in.begin(); it != in.end();) {
      //   move_outside(*it);
      //   it++;
      //   in.erase(prev(it, 1));
      // }
      // set<int> oth = in;
      // for (auto val: oth) gout(val);
      lo = t;
    } else { // erase everything not in this section
      out.clear();
      set<int> oth = in;
      for (auto val: oth) gout(val);
      hi = t-1;
    }

  }
  // cout << alr << endl;

  return lo;

}













Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:85:19: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   85 |     if (in.size() == t * d) { // all here --- erase this section
      |         ~~~~~~~~~~^~~~~~~~
insects.cpp:63:7: warning: unused variable 'alr' [-Wunused-variable]
   63 |   int alr = 0;
      |       ^~~
insects.cpp:65:7: warning: variable 'prv' set but not used [-Wunused-but-set-variable]
   65 |   int prv = -1;
      |       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 6 ms 600 KB Output is correct
8 Correct 6 ms 600 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 5 ms 856 KB Output is correct
12 Correct 5 ms 700 KB Output is correct
13 Correct 5 ms 848 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 6 ms 600 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 5 ms 612 KB Output is correct
18 Correct 5 ms 612 KB Output is correct
19 Correct 5 ms 344 KB Output is correct
20 Correct 6 ms 600 KB Output is correct
21 Correct 6 ms 856 KB Output is correct
22 Correct 7 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 6 ms 600 KB Output is correct
8 Correct 6 ms 600 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 5 ms 856 KB Output is correct
12 Correct 5 ms 700 KB Output is correct
13 Correct 5 ms 848 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 6 ms 600 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 5 ms 612 KB Output is correct
18 Correct 5 ms 612 KB Output is correct
19 Correct 5 ms 344 KB Output is correct
20 Correct 6 ms 600 KB Output is correct
21 Correct 6 ms 856 KB Output is correct
22 Correct 7 ms 460 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
24 Correct 49 ms 1104 KB Output is correct
25 Correct 38 ms 1048 KB Output is correct
26 Correct 34 ms 892 KB Output is correct
27 Correct 11 ms 600 KB Output is correct
28 Correct 29 ms 872 KB Output is correct
29 Correct 20 ms 644 KB Output is correct
30 Correct 31 ms 836 KB Output is correct
31 Correct 22 ms 600 KB Output is correct
32 Correct 32 ms 856 KB Output is correct
33 Correct 38 ms 1108 KB Output is correct
34 Correct 41 ms 800 KB Output is correct
35 Correct 34 ms 776 KB Output is correct
36 Correct 37 ms 1056 KB Output is correct
37 Correct 37 ms 1088 KB Output is correct
38 Correct 47 ms 1060 KB Output is correct
39 Correct 45 ms 1008 KB Output is correct
40 Correct 43 ms 1084 KB Output is correct
41 Correct 51 ms 1220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 10 ms 344 KB Output is correct
8 Partially correct 111 ms 1028 KB Output is partially correct
9 Partially correct 78 ms 948 KB Output is partially correct
10 Partially correct 80 ms 1080 KB Output is partially correct
11 Correct 27 ms 504 KB Output is correct
12 Partially correct 64 ms 1168 KB Output is partially correct
13 Partially correct 42 ms 756 KB Output is partially correct
14 Partially correct 76 ms 828 KB Output is partially correct
15 Partially correct 76 ms 1184 KB Output is partially correct
16 Partially correct 69 ms 936 KB Output is partially correct
17 Partially correct 74 ms 1084 KB Output is partially correct
18 Partially correct 87 ms 744 KB Output is partially correct
19 Partially correct 66 ms 1100 KB Output is partially correct
20 Partially correct 72 ms 1072 KB Output is partially correct
21 Partially correct 81 ms 968 KB Output is partially correct
22 Partially correct 96 ms 944 KB Output is partially correct
23 Partially correct 84 ms 1188 KB Output is partially correct
24 Partially correct 101 ms 1272 KB Output is partially correct
25 Partially correct 94 ms 1288 KB Output is partially correct
26 Partially correct 104 ms 1592 KB Output is partially correct
27 Partially correct 82 ms 1244 KB Output is partially correct
28 Partially correct 93 ms 1020 KB Output is partially correct
29 Partially correct 88 ms 840 KB Output is partially correct
30 Partially correct 96 ms 1152 KB Output is partially correct
31 Partially correct 81 ms 1360 KB Output is partially correct
32 Partially correct 94 ms 1240 KB Output is partially correct
33 Partially correct 90 ms 1184 KB Output is partially correct
34 Partially correct 84 ms 1480 KB Output is partially correct
35 Partially correct 88 ms 1172 KB Output is partially correct
36 Partially correct 98 ms 1160 KB Output is partially correct
37 Partially correct 90 ms 1056 KB Output is partially correct
38 Partially correct 85 ms 1168 KB Output is partially correct
39 Partially correct 116 ms 1180 KB Output is partially correct
40 Partially correct 120 ms 1172 KB Output is partially correct
41 Partially correct 89 ms 1088 KB Output is partially correct
42 Partially correct 87 ms 1312 KB Output is partially correct
43 Partially correct 7 ms 344 KB Output is partially correct
44 Partially correct 30 ms 752 KB Output is partially correct
45 Correct 35 ms 596 KB Output is correct
46 Partially correct 65 ms 1384 KB Output is partially correct
47 Partially correct 83 ms 1140 KB Output is partially correct
48 Partially correct 62 ms 944 KB Output is partially correct