제출 #1212302

#제출 시각아이디문제언어결과실행 시간메모리
1212302nerrrmin드문 곤충 (IOI22_insects)C++20
컴파일 에러
0 ms0 KiB
#include "insects.h"
#include<bits/stdc++.h>
#define pb push_back
#define pb push_back
using namespace std;


int n;
int cnt;
vector < int > fosure;
bool check(int x)
{
    vector < int > g;
    int put = fosure.size();
    for (int i = 0; i < n; ++ i)
    {
        if(!use[i])continue;
        g.pb(i);
        move_inside(i);
        if(press_button() > x)
        {
            move_outside(i);
            g.pop_back();
        }
        else put ++;
    }
    if(put == cnt * x)
    {
        for (auto x: g)
        {
            fosure[x].pb(x);
            use[x] = 0;
        }
    }
    else
    {
        
        for (auto x: g)
            move_outside(x);
    }
    
    return (put == cnt * x);
}
int min_cardinality(int N)
{

    n = N;
    for (int i = 0; i < n; ++ i)
        use[i] = 1;
    vector < int > g;
    for (int i = 0; i < n; ++ i)
    {
        g.pb(i);
        move_inside(i);
        if(press_button() == 2)
        {
            move_outside(i);
            g.pop_back();
        }
    }
    cnt = g.size();
    for (auto x: g)
        move_outside(x);

    int l = 0, r = n/cnt, mid, ans;
    while(l <= r)
    {
        int mid = (l + r)/2;
        if(check(mid))
        {
            ans = mid; l = mid + 1;

        }
        else r = mid - 1;
    }
  return ans;
}

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

insects.cpp: In function 'bool check(int)':
insects.cpp:17:13: error: 'use' was not declared in this scope; did you mean 'pause'?
   17 |         if(!use[i])continue;
      |             ^~~
      |             pause
insects.cpp:4:12: error: request for member 'push_back' in 'fosure.std::vector<int>::operator[](((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    4 | #define pb push_back
      |            ^~~~~~~~~
insects.cpp:31:23: note: in expansion of macro 'pb'
   31 |             fosure[x].pb(x);
      |                       ^~
insects.cpp:32:13: error: 'use' was not declared in this scope; did you mean 'pause'?
   32 |             use[x] = 0;
      |             ^~~
      |             pause
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:49:9: error: 'use' was not declared in this scope; did you mean 'pause'?
   49 |         use[i] = 1;
      |         ^~~
      |         pause