Submission #835539

# Submission time Handle Problem Language Result Execution time Memory
835539 2023-08-23T15:35:03 Z ma_moutahid Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 208 KB
#include "insects.h"
#include <bits/stdc++.h>

using namespace std;

#define vi vector<int>

vi d;
int parent (int x){
  if(d[x]==x)return x;
  else return d[x]=parent(d[x]);
}
void connect(int x, int y){
  d[parent(x)]=parent(y);
}
int min_cardinality(int N) {
  int n=N;
  d.resize(n);
  map<int,int>m;
  for(int i=0;i<n;i++){
    d[i]=i;
  }
  vi found(n);
  for(int i=0;i<n-1;i++){
    if(found[i])continue;
    move_inside(i);
    for(int j=i+1;j<n;j++){
      if(found[j])continue;
      move_inside(j);
      if(press_button()==1){connect(i,j);found[j]=1;}
      move_outside(j);
    }
    move_outside(i);
  }
  for(int i=0;i<n;i++){
    m[parent(i)]++;
  }
  int mn= 1e9;
  for(auto p:m){
    mn=min(mn,p.second);
  }
  return mn;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong answer.
3 Halted 0 ms 0 KB -