답안 #1074799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074799 2024-08-25T14:10:57 Z Zicrus 드문 곤충 (IOI22_insects) C++17
0 / 100
1 ms 596 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;

typedef long long ll;

int n;
vector<bool> in;
unordered_set<int> s;
int cnt;

int add(int i) {
    if (in[i]) return 0;
    move_inside(i);
    cnt++;
    in[i] = true;
    return 1;
}

int remove(int i) {
    if (!in[i]) return 0;
    move_outside(i);
    cnt--;
    in[i] = false;
    return 1;
}

int min_cardinality(int N) {
    n = N;
    cnt = 0;
    mt19937 mt(time(0));
    in = vector<bool>(n);
    for (int i = 0; i < n; i++) {
        add(i);
    }
    int mx = press_button();
    int prevSz = cnt;
    while (mx > 1) {
        int cur = mx;
        while (cur == mx) {
            int i = mt()%n;
            if (remove(i)) {
                cur = press_button();
                if (cur == mx) s.insert(i);
            }
        }
        for (auto &e : s) {
            if (add(e)) {
                cur = press_button();
                if (cur == mx) remove(e);
            }
        }
        s.clear();
        if (cnt * mx / (mx-1) == prevSz) {
            break;
        }
        prevSz = cnt;
        mx--;
    }
    return mx;
}

#ifdef TEST
#include "grader.cpp"
#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 424 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 Incorrect 0 ms 344 KB Wrong answer.
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 424 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 Incorrect 0 ms 344 KB Wrong answer.
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB Wrong answer.
6 Halted 0 ms 0 KB -