# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
836337 | 2023-08-24T10:21:29 Z | Trumling | Rarest Insects (IOI22_insects) | C++17 | 1 ms | 208 KB |
#include "insects.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second #define all(x) x.begin(),x.end() typedef long long ll; #define pb push_back #define INF 99999999999999 int min_cardinality(int N) { ll n=N; vector<int>type(n,-1); vector<int>count(n,1); ll r=0; while((N-1)>>r) r++; vector<int>go(n,(1<<r)-1); ll ans=INF; set<int>s; vector<int>v; for(int i=0;i<N;i++) { move_inside(i); ll p=press_button(); if(p!=1) move_outside(i); else { type[i]=i; v.pb(i); } } for(auto x:v) move_outside(x); for(int j=0;(1<<j)<N;j++) { for(auto x:v) { if((!((1<<j)&x)) && s.find(x)==s.end()) { s.insert(x); move_inside(x); } if(((1<<j)&x) && s.find(x)!=s.end()) { s.erase(x); move_outside(x); } } for(int i=0;i<N;i++) if(type[i]==-1) { move_inside(i); ll p=press_button(); if(p!=1) go[i]-=(1<<j); move_outside(i); } } //for(int i=0;i<N;i++) //cout<<go[i]<<' '; for(auto x:v) s.insert(x); for(int i=0;i<N;i++) if(s.find(i)==s.end()) count[go[i]]++; for(int i=0;i<N;i++) if(s.find(i)==s.end()) ans=min(ans,(ll)count[i]); return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Wrong answer. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | Wrong answer. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Incorrect | 1 ms | 208 KB | Wrong answer. |
3 | Halted | 0 ms | 0 KB | - |