답안 #977581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977581 2024-05-08T07:21:01 Z CSQ31 Toxic Gene (NOI23_toxic) C++17
컴파일 오류
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(all(p),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);
      |                         ^~
toxic.cpp:32:17: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   32 |  random_shuffle(all(p),seed);
      |                 ^~~
      |                 std::filesystem::perms::all
In file included from /usr/include/c++/10/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from toxic.cpp:2:
/usr/include/c++/10/bits/fs_fwd.h:148:7: note: 'std::filesystem::perms::all' declared here
  148 |       all  =  0777,
      |       ^~~