Submission #977583

# Submission time Handle Problem Language Result Execution time Memory
977583 2024-05-08T07:21:27 Z CSQ31 Toxic Gene (NOI23_toxic) C++17
Compilation error
0 ms 0 KB
#include "toxic.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>tox;
#define sz(a) (int)(a.size())
mt19937 seed(chrono::high_resolution_clock::now().time_since_epoch().count());
void find_toxic(vector<int>v){
    //for(int x:v)cout<<x<<" ";
   //cout<<'\n';
    if(sz(v) == 1){
        //cout<<v[0]<<'\n';
        answer_type(v[0],'T');
        tox.push_back(v[0]);
        return;
    }
    int m = sz(v)/2;
    vector<int>a,b;
    for(int i=0;i<m;i++)a.push_back(v[i]);
    for(int i=m;i<sz(v);i++)b.push_back(v[i]);

    int res = query_sample(a);
    if(res == sz(a)){ for(int x:a)answer_type(x,'R');}
    else find_toxic(a);

    res = query_sample(b);
    if(res == sz(b)){ for(int x:b)answer_type(x,'R');}
    else find_toxic(b);
}
void determine_type(int n){
	vector<int>p;
	for(int i=1;i<=n;i++)p.pb(i);
	random_shuffle(p.begin(),p.end(),seed);

    tox.clear();
    vector<int>notoxic;
    for(int i=1;i<=n;i+=8){
        vector<int>v;
        for(int j=0;j<8;j++){
            if(i+j > n)break;
            for(int k=0;k<(1<<j);k++)v.push_back(p[i+j-1]);
        }
        //for(int x:v)cout<<x<<" ";
       //cout<<'\n';
        int res = query_sample(v);
        //cout<<res<<'\n';
        if(res == sz(v)){
            for(int j=0;j<8;j++){
                if(i+j > n)break;
                notoxic.push_back(p[i+j-1]);
            }
        }else{
            vector<int>u;
            for(int j=0;j<8;j++){
                if(i+j > n)break;
                if(res & (1<<j))answer_type(p[i+j-1],'S');
                else u.push_back(p[i+j-1]);
            }
           // for(int x:u)cout<<x<<" ";
            //cout<<'\n';
            find_toxic(u);
            //cout<<"TES"<<'\n';
        }
    }
    //for(int x:tox)cout<<x<<" ";
    //cout<<'\n';
    //for(int x:notoxic)cout<<x<<" ";
    //cout<<'\n';
    for(int i=0;i<sz(notoxic);i+=8){
        vector<int>v;
        for(int j=0;j<8;j++){
            if(i+j >= sz(notoxic))break;
            for(int k=0;k<(1<<j);k++)v.push_back(notoxic[i+j]);

        }
        v.push_back(tox[0]);
        int res = query_sample(v);
        for(int j=0;j<8;j++){
            if(i+j >= sz(notoxic))break;
            if(res & (1<<j))answer_type(notoxic[i+j],'S');
            else answer_type(notoxic[i+j],'R');
        }
    }

}

Compilation message

toxic.cpp: In function 'void determine_type(int)':
toxic.cpp:31:25: error: 'class std::vector<int>' has no member named 'pb'
   31 |  for(int i=1;i<=n;i++)p.pb(i);
      |                         ^~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from toxic.cpp:2:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::random_shuffle(_RAIter, _RAIter, _Generator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Generator = std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>&]':
toxic.cpp:32:39:   required from here
/usr/include/c++/10/bits/stl_algo.h:4636:48: error: no match for call to '(std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>) (__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
 4636 |    _RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/random:49,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:108,
                 from toxic.cpp:2:
/usr/include/c++/10/bits/random.h:563:7: note: candidate: 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::operator()() [with _UIntType = long unsigned int; long unsigned int __w = 32; long unsigned int __n = 624; long unsigned int __m = 397; long unsigned int __r = 31; _UIntType __a = 2567483615; long unsigned int __u = 11; _UIntType __d = 4294967295; long unsigned int __s = 7; _UIntType __b = 2636928640; long unsigned int __t = 15; _UIntType __c = 4022730752; long unsigned int __l = 18; _UIntType __f = 1812433253; std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type = long unsigned int]'
  563 |       operator()();
      |       ^~~~~~~~
/usr/include/c++/10/bits/random.h:563:7: note:   candidate expects 0 arguments, 1 provided