# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1057750 | 2024-08-14T05:11:21 Z | Forested | Rarest Insects (IOI22_insects) | C++17 | 155 ms | 1264 KB |
#include <bits/stdc++.h> using namespace std; using i32 = int; using i64 = long long; template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; template <typename T> using VVV = V<VV<T>>; template <typename T> bool chmin(T &x, const T &y) { if (x > y) { x = y; return true; } } template <typename T> bool chmax(T &x, const T &y) { if (x < y) { x = y; return true; } } #define OVERRIDE4(a, b, c, d, ...) d #define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i) #define REP3(i, l, r) for (i32 i = (i32)(l); i < (i32)(r); ++i) #define REP(...) OVERRIDE4(__VA_ARGS__, REP3, REP2)(__VA_ARGS__) #define PER2(i, n) for (i32 i = (i32)(n)-1; i >= 0; --i) #define PER3(i, l, r) for (i32 i = (i32)(r)-1; i >= (i32)(l); --i) #define PER(...) OVERRIDE4(__VA_ARGS__, REP3, REP2)(__VA_ARGS__) #define ALL(x) begin(x), end(x) #define LEN(x) (i32) size(x) void dbg(i32 x) { cerr << x; } void dbg(i64 x) { cerr << x; } template <typename T, typename U> void dbg(pair<T, U> p) { cerr << '('; dbg(p.first); cerr << ", "; dbg(p.second); cerr << ')'; } template <typename T> void dbg(V<T> arr) { cerr << '['; REP(i, LEN(arr)) { if (i) { cerr << ", "; } dbg(arr[i]); } cerr << ']'; } void debug() { cerr << '\n'; } template <typename Head, typename... Tail> void debug(Head head, Tail... tail) { dbg(head); cerr << ", "; debug(tail...); } #ifdef DEBUGF #define DBG(...) \ do { \ cerr << #__VA_ARGS__ << " : "; \ debug(__VA_ARGS__); \ } while (false) #else #define DBG(...) (void)0 #endif #include "insects.h" i32 min_cardinality(i32 n) { i32 kind = 0; V<i32> rem; REP(i, n) { move_inside(i); if (press_button() == 1) { ++kind; rem.push_back(i); } else { move_outside(i); } } for (i32 ele : rem) { move_outside(ele); } rem.clear(); auto judge = [&](i32 th) -> bool { REP(i, n) { move_inside(i); if (press_button() <= th) { rem.push_back(i); } else { move_outside(i); } } bool ans = (LEN(rem) == (i64)th * kind); for (i32 ele : rem) { move_outside(ele); } rem.clear(); return ans; }; i32 ok = 1, ng = n + 1; while (ng - ok > 1) { i32 mid = (ok + ng) / 2; (judge(mid) ? ok : ng) = mid; } return ok; }
# | Verdict | Execution time | Memory | 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 | 1 ms | 344 KB | Output is correct |
6 | Correct | 7 ms | 432 KB | Output is correct |
7 | Correct | 6 ms | 600 KB | Output is correct |
8 | Correct | 6 ms | 344 KB | Output is correct |
9 | Correct | 6 ms | 344 KB | Output is correct |
10 | Correct | 7 ms | 344 KB | Output is correct |
11 | Correct | 8 ms | 344 KB | Output is correct |
12 | Correct | 7 ms | 344 KB | Output is correct |
13 | Correct | 6 ms | 344 KB | Output is correct |
14 | Correct | 9 ms | 440 KB | Output is correct |
15 | Correct | 7 ms | 344 KB | Output is correct |
16 | Correct | 7 ms | 344 KB | Output is correct |
17 | Correct | 6 ms | 344 KB | Output is correct |
18 | Correct | 7 ms | 344 KB | Output is correct |
19 | Correct | 7 ms | 344 KB | Output is correct |
20 | Correct | 6 ms | 344 KB | Output is correct |
21 | Correct | 9 ms | 600 KB | Output is correct |
22 | Correct | 6 ms | 436 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 1 ms | 344 KB | Output is correct |
6 | Correct | 7 ms | 432 KB | Output is correct |
7 | Correct | 6 ms | 600 KB | Output is correct |
8 | Correct | 6 ms | 344 KB | Output is correct |
9 | Correct | 6 ms | 344 KB | Output is correct |
10 | Correct | 7 ms | 344 KB | Output is correct |
11 | Correct | 8 ms | 344 KB | Output is correct |
12 | Correct | 7 ms | 344 KB | Output is correct |
13 | Correct | 6 ms | 344 KB | Output is correct |
14 | Correct | 9 ms | 440 KB | Output is correct |
15 | Correct | 7 ms | 344 KB | Output is correct |
16 | Correct | 7 ms | 344 KB | Output is correct |
17 | Correct | 6 ms | 344 KB | Output is correct |
18 | Correct | 7 ms | 344 KB | Output is correct |
19 | Correct | 7 ms | 344 KB | Output is correct |
20 | Correct | 6 ms | 344 KB | Output is correct |
21 | Correct | 9 ms | 600 KB | Output is correct |
22 | Correct | 6 ms | 436 KB | Output is correct |
23 | Correct | 52 ms | 340 KB | Output is correct |
24 | Correct | 52 ms | 344 KB | Output is correct |
25 | Correct | 43 ms | 344 KB | Output is correct |
26 | Correct | 53 ms | 436 KB | Output is correct |
27 | Correct | 59 ms | 432 KB | Output is correct |
28 | Correct | 53 ms | 600 KB | Output is correct |
29 | Correct | 50 ms | 344 KB | Output is correct |
30 | Correct | 44 ms | 344 KB | Output is correct |
31 | Correct | 35 ms | 432 KB | Output is correct |
32 | Correct | 48 ms | 344 KB | Output is correct |
33 | Correct | 62 ms | 600 KB | Output is correct |
34 | Correct | 49 ms | 344 KB | Output is correct |
35 | Correct | 52 ms | 600 KB | Output is correct |
36 | Correct | 64 ms | 344 KB | Output is correct |
37 | Correct | 48 ms | 344 KB | Output is correct |
38 | Correct | 62 ms | 440 KB | Output is correct |
39 | Correct | 53 ms | 600 KB | Output is correct |
40 | Correct | 54 ms | 436 KB | Output is correct |
41 | Correct | 48 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | Partially correct | 0 ms | 344 KB | Output is partially correct |
7 | Partially correct | 118 ms | 664 KB | Output is partially correct |
8 | Partially correct | 109 ms | 1264 KB | Output is partially correct |
9 | Partially correct | 111 ms | 668 KB | Output is partially correct |
10 | Partially correct | 122 ms | 680 KB | Output is partially correct |
11 | Partially correct | 99 ms | 436 KB | Output is partially correct |
12 | Partially correct | 115 ms | 684 KB | Output is partially correct |
13 | Partially correct | 111 ms | 664 KB | Output is partially correct |
14 | Partially correct | 116 ms | 444 KB | Output is partially correct |
15 | Partially correct | 124 ms | 1116 KB | Output is partially correct |
16 | Partially correct | 120 ms | 676 KB | Output is partially correct |
17 | Partially correct | 116 ms | 568 KB | Output is partially correct |
18 | Partially correct | 119 ms | 680 KB | Output is partially correct |
19 | Partially correct | 127 ms | 644 KB | Output is partially correct |
20 | Partially correct | 115 ms | 920 KB | Output is partially correct |
21 | Partially correct | 119 ms | 660 KB | Output is partially correct |
22 | Partially correct | 81 ms | 676 KB | Output is partially correct |
23 | Partially correct | 112 ms | 592 KB | Output is partially correct |
24 | Partially correct | 123 ms | 580 KB | Output is partially correct |
25 | Partially correct | 101 ms | 672 KB | Output is partially correct |
26 | Partially correct | 88 ms | 668 KB | Output is partially correct |
27 | Partially correct | 112 ms | 568 KB | Output is partially correct |
28 | Partially correct | 118 ms | 908 KB | Output is partially correct |
29 | Partially correct | 138 ms | 632 KB | Output is partially correct |
30 | Partially correct | 109 ms | 804 KB | Output is partially correct |
31 | Partially correct | 108 ms | 428 KB | Output is partially correct |
32 | Partially correct | 105 ms | 568 KB | Output is partially correct |
33 | Partially correct | 124 ms | 556 KB | Output is partially correct |
34 | Partially correct | 110 ms | 676 KB | Output is partially correct |
35 | Partially correct | 117 ms | 896 KB | Output is partially correct |
36 | Partially correct | 107 ms | 680 KB | Output is partially correct |
37 | Partially correct | 112 ms | 916 KB | Output is partially correct |
38 | Partially correct | 108 ms | 860 KB | Output is partially correct |
39 | Partially correct | 119 ms | 668 KB | Output is partially correct |
40 | Partially correct | 96 ms | 428 KB | Output is partially correct |
41 | Partially correct | 111 ms | 872 KB | Output is partially correct |
42 | Partially correct | 155 ms | 592 KB | Output is partially correct |
43 | Partially correct | 23 ms | 344 KB | Output is partially correct |
44 | Partially correct | 87 ms | 588 KB | Output is partially correct |
45 | Partially correct | 121 ms | 580 KB | Output is partially correct |
46 | Partially correct | 101 ms | 576 KB | Output is partially correct |
47 | Partially correct | 98 ms | 1108 KB | Output is partially correct |
48 | Partially correct | 114 ms | 916 KB | Output is partially correct |