Submission #836319

# Submission time Handle Problem Language Result Execution time Memory
836319 2023-08-24T10:09:09 Z Trumling Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 332 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);
      vector<int>go(n,0);

      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(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

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:74:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   74 |     for(int i=0;i<N;i++)
      |     ^~~
insects.cpp:78:7: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   78 |       return ans;
      |       ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Incorrect 0 ms 208 KB Wrong answer.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Incorrect 0 ms 208 KB Wrong answer.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Partially correct 0 ms 208 KB Output is partially correct
6 Incorrect 1 ms 208 KB Wrong answer.
7 Halted 0 ms 0 KB -