답안 #1059497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059497 2024-08-15T03:47:41 Z shiomusubi496 드문 곤충 (IOI22_insects) C++17
0 / 100
223 ms 412 KB
#include "insects.h"
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)

#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)

using namespace std;

using ll = long long;

template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; }
template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; }

int min_cardinality(int N) {
    rep (i, N) move_inside(i);
    int x = press_button();
    vector<bool> flag(N, true);
    int cnt = -1;
    int ans = N;
    int sm = 0;
    rrep2 (t, 1, x + 1) {
        int j = -1;
        rep (i, N) {
            if (flag[i]) {
                move_outside(i);
                if (press_button() == t - 1) {
                    j = i;
                    flag[i] = false;
                    break;
                }
            }
        }
        int cnt2 = 1;
        rep (i, j) {
            if (flag[i]) {
                move_inside(i);
                if (N - j - 1 < cnt2 * (t - 1)) continue;
                if (press_button() == t) {
                    flag[i] = false;
                    ++cnt2;
                    move_outside(i);
                }
            }
        }
        sm += cnt2;
        if (cnt != cnt2) {
            cnt = cnt2;
            ans = t;
        }
        if ((t - 1) * cnt2 + sm == N) return ans;
    }
    return ans;
}
# 결과 실행 시간 메모리 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 0 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Incorrect 10 ms 344 KB Wrong answer.
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Incorrect 10 ms 344 KB Wrong answer.
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
9 Incorrect 223 ms 412 KB Wrong answer.
10 Halted 0 ms 0 KB -