제출 #708803

#제출 시각아이디문제언어결과실행 시간메모리
708803t6twotwoRarest Insects (IOI22_insects)C++17
컴파일 에러
0 ms0 KiB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int min_cardinality(int n) {
    vector<bool> in(n);
    for (int i = 0; i < n; i++) {
        move_inside(i);
        if (press_button() == 2) move_outside(i);
        else in[i] = 1;
    }
    int type = 0;
    vector<bool> blocked(n);
    for (int i = 0; i < n; i++) {
        if (in[i]) {
            type++;
            blocked[i] = 1;
        }
    }
    int lo = 1, hi = n / type, cnt = type;
    while (lo < hi) {
        int x = (lo + hi + 1) / 2;
        vector<int> p(n);
        iota(p.begin(), p.end(), 0);
        random_shuffle(p.begin(), p.end());
        for (int i = 0; i < n; i++) {
            if (blocked[p[i]] || cnt == x * type) continue;
            move_inside(p[i]);
            if (press_button() == x + 1) move_outside(p[i];
            else in[p[i]] = 1, cnt++;
        }
        int t = cnt;
        for (int i = 0; i < n; i++) {
            if (blocked[i]) continue;
            if (in[i]) {
                if (t == x * type) {
                    blocked[i] = 1;
                } else {
                    in[i] = 0;
                    cnt--;
                    move_outside(i);
                }
            } else if (t != x * type) {
                blocked[i] = 1;
            }
        }
        if (t == x * type) lo = x;
        else hi = t / type;
    }
    return lo;
}

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:29:59: error: expected ')' before ';' token
   29 |             if (press_button() == x + 1) move_outside(p[i];
      |                                                      ~    ^
      |                                                           )