Submission #838469

# Submission time Handle Problem Language Result Execution time Memory
838469 2023-08-27T07:09:51 Z Trumling Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 336 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()

struct Trum
{
  int l,r;
  vector<int> here;

};
int min_cardinality(int N) 
{
ll n=N;
vector<int>type(n,-1);
vector<int>count(n,1);
vector<int>v;
set<int>s;
  for(int i=0;i<N;i++)
    {
      move_inside(i);
      ll p=press_button();
      if(p!=1)
      move_outside(i);
      else
      {
       type[i]=i;
       s.insert(i);
       v.pb(i);
      }
    }
  Trum curr;
  for(int i=0;i<N;i++)
  if(type[i]==-1)
  curr.here.pb(i);

  
  queue<Trum>q;
  
  curr.l=0;
  curr.r=v.size()-1;

  q.push(curr);

  while(!q.empty())
  {
    curr=q.front();
    q.pop();

    if(curr.l==curr.r)
    {
      count[v[curr.l]]+=curr.here.size();
      continue;
    }

    if(!curr.here.size())
    continue;

    ll mid=(curr.l+curr.r)/2;

    for(int i=curr.l;i<=curr.r;i++)
    {
      if(i<=mid && s.find(v[i])==s.end())
      {
        move_inside(v[i]);
        s.insert(v[i]);
      }

      if(i>mid && s.find(v[i])!=s.end())
      {
        move_outside(v[i]);
        s.erase(v[i]);
      }
    }
    Trum l,r;
    l.l=curr.l;
    l.r=mid;

    r.l=mid+1;
    r.r=curr.r;
    for(auto x:curr.here)
    {
      move_inside(x);
      ll p=press_button();
      if(p!=1)
      l.here.pb(x);
      else
      r.here.pb(x);

      move_outside(x);
    }

    q.push(l);
    q.push(r);
    
  }


}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:107:1: warning: no return statement in function returning non-void [-Wreturn-type]
  107 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 296 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 296 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -