Submission #1356158

#TimeUsernameProblemLanguageResultExecution timeMemory
1356158vjudge1드문 곤충 (IOI22_insects)C++20
Compilation error
0 ms0 KiB
#include "insects.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;

int min_cardinality(int n){
    vector<int> a,b;
    for(int i=0;i<n;i++) a.push_back(i);

    // D
    for(int i=0;i<n;i++){
        move_inside(i);
        if(press_button()>1) move_outside(i);
        else b.push_back(i);
    }

    int d = b.size();

    vector<int> u(n,0), na;
    for(auto x:b) u[x]=1;
    for(auto x:a) if(!u[x]) na.push_back(x);
    a = na;

    int l=1, r=n/d;
    int tot=d;

    while(l<r){
        int m=(l+r+1)/2;

        vector<int> add;
        vector<int> cur=a;

        random_shuffle(cur.begin(),cur.end());

        for(auto x:cur){
            move_inside(x);
            if(press_button()>m) move_outside(x);
            else{
                add.push_back(x);
                tot++;
            }
            if(tot==m*d) break;
        }

        if(tot==m*d){
            l=m;

            vector<int> mark(n,0), nxt;
            for(auto x:add) mark[x]=1;
            for(auto x:a) if(!mark[x]) nxt.push_back(x);
            a=nxt;
        }
        else{
            r=m-1;
            for(auto x:add){
                move_outside(x);
                tot--;
            }
        }
    }

    return l;
}

Compilation message (stderr)

insects.cpp: In function 'long long int min_cardinality(long long int)':
insects.cpp:33:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   33 |         random_shuffle(cur.begin(),cur.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:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cccUBYIg.o: in function `main':
stub.cpp:(.text.startup+0x5c): undefined reference to `min_cardinality(int)'
collect2: error: ld returned 1 exit status