답안 #858824

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858824 2023-10-09T08:38:12 Z MasterDobby 드문 곤충 (IOI22_insects) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "insects.h"
#define all(a) a.begin(),a.end()
#define pii pair<int,int>

using namespace std;
using ll = long long;

const int N=1e5+10;
bitset<2020> ch;

int min_cardinality(int n){
    int cnt=1;
    ch[0]=1;
    move_inside(0);
    for(int i=1;i<n;i++){
        move_inside(i);
        int num=press_button();
        if(num==1){
            ch[i]=1;
            cnt++;
        }
        else{
            move_outside(i);
        }
    }
    int cnt2=cnt,ans=1;
    for(int i=2;i<=cnt;i++){
        for(int j=0;j<n;j++){
            if(ch[j]) continue;
            if(cnt2==cnt*i) break;
            move_inside(j);
            int num=press_button()
            if(num==i){
                ch[j]=1;
                cnt2++;
            }
            else{
                move_outside(j);
            }
        }
        if(cnt2!=cnt*i) break;
        ans=i;
    }
    return ans;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:34:13: error: expected ',' or ';' before 'if'
   34 |             if(num==i){
      |             ^~
insects.cpp:38:13: error: 'else' without a previous 'if'
   38 |             else{
      |             ^~~~
insects.cpp:33:17: warning: unused variable 'num' [-Wunused-variable]
   33 |             int num=press_button()
      |                 ^~~