Submission #1200872

#TimeUsernameProblemLanguageResultExecution timeMemory
1200872Zbyszek99Rarest Insects (IOI22_insects)C++20
0 / 100
0 ms412 KiB
#include "insects.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define ull unsigned long long #define ff first #define ss second #define pii pair<int,int> #define pll pair<long long, long long> #define vi vector<int> #define vl vector<long long> #define pb push_back #define rep(i, b) for(int i = 0; i < (b); ++i) #define rep2(i,a,b) for(int i = a; i <= (b); ++i) #define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c) #define count_bits(x) __builtin_popcountll((x)) #define all(x) (x).begin(),(x).end() #define siz(x) (int)(x).size() #define forall(it,x) for(auto& it:(x)) using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());} ll los(ll a, ll b) {return a + (mt() % (b-a+1));} const int INF = 1e9+50; const ll INF_L = 1e18+40; const ll MOD = 1e9+7; int solve(int P, vi r) { shuffle(all(r),mt); if(P == 1) return siz(r); if(P == 2) { forall(it,r) move_inside(it); int p = press_button(); forall(it,r) move_outside(it); return p; } if(siz(r) < P) { return 0; } if(siz(r) < P*2) { int p2 = 0; forall(it,r) { move_inside(it); if(press_button() == 1) { p2++; } else { move_outside(it); } } if(p2 != P) return 0; return 1; } vi Ps; vi new_r; vi new_r2; forall(it,r) { move_inside(it); if(press_button() == 2) { new_r.pb(it); move_outside(it); } else { if(siz(Ps) == (P+1)/2) { new_r2.pb(it); move_outside(it); } else { Ps.pb(it); } } } forall(it,Ps) move_outside(it); return min(solve(siz(Ps),new_r)+1,solve(P-siz(Ps),new_r2)); } int min_cardinality(int n) { random_start(); vi nums; rep(i,n) nums.pb(i); shuffle(all(nums),mt); vi rest; vi Ps; forall(it,nums) { move_inside(it); if(press_button() == 2) { rest.pb(it); move_outside(it); } else { Ps.pb(it); } } forall(it,Ps) move_outside(it); return solve(siz(Ps),rest)+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...