제출 #836347

#제출 시각아이디문제언어결과실행 시간메모리
836347TrumlingRarest Insects (IOI22_insects)C++17
47.51 / 100
206 ms464 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(int i=0;i<N;i++)
      if(type[i]==-1)
        count[go[i]]++;

    for(int i=0;i<N;i++)
      if(type[i]!=-1)
        ans=min(ans,(ll)count[i]);

      return ans;
    }

컴파일 시 표준 에러 (stderr) 메시지

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