Submission #836337

#TimeUsernameProblemLanguageResultExecution timeMemory
836337TrumlingRarest Insects (IOI22_insects)C++17
0 / 100
1 ms208 KiB
#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 (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:82:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   82 |     for(int i=0;i<N;i++)
      |     ^~~
insects.cpp:86:7: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   86 |       return ans;
      |       ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...