제출 #1353968

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

int min_cardinality(int N) {
    set<int> inside, active;
    int U = 0;
    
    for (int i = 0; i<N; i++){
        active.insert(i);
    }
    vector<int> fnd;
    for (auto u : active){
        move_inside(u);
        int x = press_button();
        if (x > 1) move_outside(u);
        else fnd.push_back(u);
    }
    U = fnd.size();
    sort(fnd.begin(), fnd.end());
    for (auto u : fnd) active.erase(u);
    
    int lo = 1;
    int hi = N/U;

    int tot = U;    
    while (lo < hi){
        hi = min(hi, lo + ((int)active.size()/U));
        if (lo == hi) break;
        
        int mid = (lo+hi+1)/2;
        fnd.clear();
        
        vector<int> act(active.begin(), active.end());
        mt19937 rng(1337);
        shuffle(act.begin(), act.end());
        
        for (auto u : act){
            move_inside(u);
            int x = press_button();
            if (x > mid) move_outside(u);
            else{
                fnd.push_back(u);
                tot++;
            }
            if (tot == mid * U) break;
        }
        if (tot == mid * U){
            lo = mid;
            for (auto u : fnd) active.erase(u);
        }
        else if (tot < mid * U){
            hi = mid-1;
            active.clear();
            for (auto u : fnd){
                active.insert(u);
                move_outside(u);
                tot--;
            }
        }
    }
    return lo;
}

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

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:36:16: error: no matching function for call to 'shuffle(std::vector<int>::iterator, std::vector<int>::iterator)'
   36 |         shuffle(act.begin(), act.end());
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from insects.cpp:2:
/usr/include/c++/13/bits/stl_algo.h:3742:5: note: candidate: 'template<class _RAIter, class _UGenerator> void std::shuffle(_RAIter, _RAIter, _UGenerator&&)'
 3742 |     shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~
/usr/include/c++/13/bits/stl_algo.h:3742:5: note:   template argument deduction/substitution failed:
insects.cpp:36:16: note:   candidate expects 3 arguments, 2 provided
   36 |         shuffle(act.begin(), act.end());
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~