#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()==2){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 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
164 ms |
280 KB |
Output is correct |
8 |
Correct |
11 ms |
284 KB |
Output is correct |
9 |
Correct |
12 ms |
284 KB |
Output is correct |
10 |
Correct |
3 ms |
208 KB |
Output is correct |
11 |
Correct |
43 ms |
276 KB |
Output is correct |
12 |
Correct |
5 ms |
208 KB |
Output is correct |
13 |
Correct |
11 ms |
280 KB |
Output is correct |
14 |
Correct |
4 ms |
208 KB |
Output is correct |
15 |
Correct |
7 ms |
208 KB |
Output is correct |
16 |
Correct |
8 ms |
208 KB |
Output is correct |
17 |
Correct |
12 ms |
304 KB |
Output is correct |
18 |
Correct |
8 ms |
208 KB |
Output is correct |
19 |
Correct |
7 ms |
208 KB |
Output is correct |
20 |
Correct |
32 ms |
280 KB |
Output is correct |
21 |
Correct |
60 ms |
280 KB |
Output is correct |
22 |
Correct |
56 ms |
288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
164 ms |
280 KB |
Output is correct |
8 |
Correct |
11 ms |
284 KB |
Output is correct |
9 |
Correct |
12 ms |
284 KB |
Output is correct |
10 |
Correct |
3 ms |
208 KB |
Output is correct |
11 |
Correct |
43 ms |
276 KB |
Output is correct |
12 |
Correct |
5 ms |
208 KB |
Output is correct |
13 |
Correct |
11 ms |
280 KB |
Output is correct |
14 |
Correct |
4 ms |
208 KB |
Output is correct |
15 |
Correct |
7 ms |
208 KB |
Output is correct |
16 |
Correct |
8 ms |
208 KB |
Output is correct |
17 |
Correct |
12 ms |
304 KB |
Output is correct |
18 |
Correct |
8 ms |
208 KB |
Output is correct |
19 |
Correct |
7 ms |
208 KB |
Output is correct |
20 |
Correct |
32 ms |
280 KB |
Output is correct |
21 |
Correct |
60 ms |
280 KB |
Output is correct |
22 |
Correct |
56 ms |
288 KB |
Output is correct |
23 |
Correct |
10 ms |
300 KB |
Output is correct |
24 |
Incorrect |
315 ms |
208 KB |
Too many queries. |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
17 ms |
304 KB |
Output is correct |
8 |
Incorrect |
251 ms |
208 KB |
Too many queries. |
9 |
Halted |
0 ms |
0 KB |
- |