#include<bits/stdc++.h>
#include "insects.h"
#define ll int
#define ull unsigned long long
#define ld double
#define pb push_back
#define pf push_front
#define vi vector<ll>
#define vii vector<vi>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()
#define fi first
#define se second
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e18;
const ll base = 31;
const ll blocksz = 320;
const ll N = 1e5+8;
int col[N];
int c[N];
int min_cardinality(int n){
int now_col = 1;
for(int i = 0; i < n; i++){
if(!col[i]){
vi clear_col;
clear_col.pb(i);
move_inside(i), col[i] = now_col;
int cnt = 1;
for(int j = i+1; j < n; j++){
if(!col[j]){
move_inside(j);
int rep = press_button();
if(rep > cnt) col[j] = now_col, cnt++, clear_col.pb(j);
else move_outside(j);
}
}
for(int x:clear_col) move_outside(x);
now_col++;
}
}
for(int i = 0; i < n; i++) c[col[i]]++;
int ans = N;
for(int i = 0; i < n; i++){
if(c[col[i]] > 0) ans = min(ans,c[col[i]]);
}
return ans;
}
Compilation message
insects.cpp:17:16: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
17 | const ll inf = 1e18;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
131 ms |
340 KB |
Output is correct |
8 |
Correct |
9 ms |
344 KB |
Output is correct |
9 |
Correct |
7 ms |
344 KB |
Output is correct |
10 |
Correct |
4 ms |
344 KB |
Output is correct |
11 |
Correct |
28 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
5 ms |
344 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
344 KB |
Output is correct |
16 |
Correct |
4 ms |
340 KB |
Output is correct |
17 |
Correct |
5 ms |
344 KB |
Output is correct |
18 |
Correct |
6 ms |
344 KB |
Output is correct |
19 |
Correct |
10 ms |
344 KB |
Output is correct |
20 |
Correct |
19 ms |
344 KB |
Output is correct |
21 |
Correct |
38 ms |
344 KB |
Output is correct |
22 |
Correct |
70 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
131 ms |
340 KB |
Output is correct |
8 |
Correct |
9 ms |
344 KB |
Output is correct |
9 |
Correct |
7 ms |
344 KB |
Output is correct |
10 |
Correct |
4 ms |
344 KB |
Output is correct |
11 |
Correct |
28 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
5 ms |
344 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
344 KB |
Output is correct |
16 |
Correct |
4 ms |
340 KB |
Output is correct |
17 |
Correct |
5 ms |
344 KB |
Output is correct |
18 |
Correct |
6 ms |
344 KB |
Output is correct |
19 |
Correct |
10 ms |
344 KB |
Output is correct |
20 |
Correct |
19 ms |
344 KB |
Output is correct |
21 |
Correct |
38 ms |
344 KB |
Output is correct |
22 |
Correct |
70 ms |
344 KB |
Output is correct |
23 |
Correct |
5 ms |
344 KB |
Output is correct |
24 |
Incorrect |
222 ms |
344 KB |
Too many queries. |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
9 ms |
344 KB |
Output is correct |
8 |
Incorrect |
235 ms |
344 KB |
Too many queries. |
9 |
Halted |
0 ms |
0 KB |
- |