답안 #859223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
859223 2023-10-10T01:57:49 Z kim 드문 곤충 (IOI22_insects) C++17
컴파일 오류
0 ms 0 KB
#include "insects.h"
#include<bits/stdc++.h>

#define in move_inside
#define press press_button
#define out move_outside

vector<int> vec0;
int p;
int n;

bool check(int k){
    int cnt=0;
    for(int i=1;i<=n;++i){
        in(i), ++cnt;
        if(press()>k) out(i),--cnt;
    }
    if(cnt==p*k) return 1;
    return 0;
}

int min_cardinality(int N){
    n=N;
    for(int i=1;i<=n;++i){
        in(i), vec0.push_back(i);
        if(press()>1) out(i),vec.pop_back();
    }
    p=vec0.size();

    int l=1,r=n/p;
    while(l<r){
        int mid=l+(r-l+1>>1);
        if(check(mid)) l=mid;
        else r=mid-1;
    }
    return l;
}

Compilation message

insects.cpp:8:1: error: 'vector' does not name a type
    8 | vector<int> vec0;
      | ^~~~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:25:16: error: 'vec0' was not declared in this scope
   25 |         in(i), vec0.push_back(i);
      |                ^~~~
insects.cpp:26:30: error: 'vec' was not declared in this scope
   26 |         if(press()>1) out(i),vec.pop_back();
      |                              ^~~
insects.cpp:28:7: error: 'vec0' was not declared in this scope
   28 |     p=vec0.size();
      |       ^~~~
insects.cpp:32:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |         int mid=l+(r-l+1>>1);
      |                    ~~~^~