Submission #940975

# Submission time Handle Problem Language Result Execution time Memory
940975 2024-03-08T03:53:25 Z hotboy2703 Toxic Gene (NOI23_toxic) C++17
Compilation error
0 ms 0 KB
#include "toxic.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
using ull = unsigned long long;
using ld = long double;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
#define MP make_pair
ll ans[310];
ll wow = 0;
ll query(vector <ll> all){
    wow++;
    return query_sample(all);
}
//0 thuong 1 doc 2 manh
void solve(vector <ll> all){
    if (sz(all) == 1){ans[all.back()]=1;return;}
    ll mid = sz(all)/2;
    vector <ll> L;
    vector <ll> R;
    for (ll i = 0;i < mid;i++)L.push_back(all[i]);
    for (ll i = mid;i < sz(all);i ++)R.push_back(all[i]);
    if (query(L)!=sz(L)){
        solve(L);
    }
    else solve(R);
}
void determine_type(int n){
    wow = 0;
    for (ll i = 1;i <= n;i ++)ans[i] = -1;
    vector <ll> pos;
    for (ll i=  1;i <= n;i ++){
        pos.push_back(i);
    }
    shuffle(pos.begin(),pos.end(),rng);
    while (sz(pos)){
        vector <ll> cur;
        while (sz(pos) && sz(cur) < 8){cur.push_back(pos.back());pos.pop_back();}
        vector <ll> all;
        for (ll j= 0 ;j < sz(cur);j ++){
            for (ll k= 0 ;k < MASK(j);k ++)all.push_back(cur[j]);
        }
        ll sus = query(all);
//        for (auto x:all)cout<<x<<' ';
//        cout<<'\n';
        if (sus != sz(all)){
            vector <ll> tmp;
            for (ll j = 0;j < sz(cur);j ++){
                if (BIT(sus,j))ans[cur[j]] = 2;
                else tmp.push_back(cur[j]);
            }
//            for (auto x:tmp)cout<<x<<' ';
//            cout<<'\n';
            cur = tmp;
            solve(cur);
//            for (auto x:cur)cout<<ans[x]<<' ';
//            cout<<'\n';
            bool ok = 0;
            for (auto x:cur){
                if (ans[x] == 1){ok = 1;continue;}
                if (!ok)ans[x] = 0;
                else pos.push_back(x);
            }
        }
//        cout<<sz(pos)<<endl;
    }
//    assert(wow <= 90 + 35);
//    cout<<"WHAT "<<wow<<endl;
	ll poison = -1;
	vector <ll> rem;
    for (ll i = 1;i <= n;i ++){
        if (ans[i] == 1){
            poison = i;
        }
        else{
            rem.push_back(i);
        }
    }
//    for (auto x:rem)cout<<x<<' ';
//    cout<<'\n';
    while (sz(rem)){
        vector <ll> cur;
        while (sz(rem) && sz(cur) < 8){cur.push_back(rem.back());rem.pop_back();}
        vector <ll> all;
        for (ll j = 0;j < sz(cur);j ++){
            for (ll k = 0;k < MASK(j);k ++){
                all.push_back(cur[j]);
            }
        }
        all.push_back(poison);
        ll x = query(all);
        for (ll j = 0;j < sz(cur);j ++){
            if (BIT(x,j)){
                ans[cur[j]] = 2;
            }
            else ans[cur[j]] = 0;
        }
    }
    for (ll i = 1;i <= n;i ++){
        if (ans[i]==0)answer_type(i,'R');
        if (ans[i]==2)answer_type(i,'S');
        if (ans[i]==1)answer_type(i,'T');
    }
}

Compilation message

toxic.cpp: In function 'void determine_type(int)':
toxic.cpp:40:35: error: 'rng' was not declared in this scope
   40 |     shuffle(pos.begin(),pos.end(),rng);
      |                                   ^~~