# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024480 | Otalp | Rarest Insects (IOI22_insects) | C++17 | 233 ms | 1196 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
void put(int x){
move_inside(x - 1);
}
void pop(int x){
move_outside(x - 1);
}
int get(){
return press_button();
}
int min_cardinality(int N) {
int n = N;
vector<int> d;
map<int, int> q, cnt;
int ls = 0;
for(int i=1; i<=n; i++){
put(i);
//cout<<get()<<' '<<i<<'\n';
if(get() == 1){
q[i] = ++ls;
cnt[ls] = 1;
d.pb(i);
continue;
}
for(int x: d){
pop(x);
if(get() == 1){
cnt[q[x]] ++;
q[i] = q[x];
}
put(x);
}
pop(i);
}
//for(int x: d) cout<<x<<' ';
//cout<<'\n';
int ans = -1, mn = 1e9;
for(int i=1; i<=n; i++){
//cout<<i<<' '<<q[i]<<'\n';
if(cnt[q[i]] < mn){
ans = i;
mn = cnt[q[i]];
}
}
return mn;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |