#include <bits/stdc++.h>
using namespace std;
void move_inside(int i);
void move_outside(int i);
int press_button();
int min_cardinality(int n)
{
set<int> machine;
int sm=1;
machine.insert(0);
move_inside(0);
for(int i=1;i<n;i++)
{
move_inside(i);
if(press_button()==1)
{
sm++;
machine.insert(i);
}
else
move_outside(i);
}
// for(auto i:machine)
// move_outside(i),sm--;
// machine.clear();
int sz=sm,np=n;
while(1)
{
int mid=(np)/sz;
// cout<<"AT "<<np<<' '<<sz<<' '<<mid<<endl;
for(auto i:machine)
move_outside(i);
sm=0;
machine.clear();
for(int i=0;i<n and sm<(sz*mid);i++)
{
if(machine.find(i)==machine.end())
{
move_inside(i);
if(press_button()>mid)
{
move_outside(i);
}
else
{
sm++;
machine.insert(i);
}
}
}
if(sm==((sz*mid)))
{
return mid; // this is the answer
}
else{
np=sm;
}
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
7 ms |
436 KB |
Output is correct |
10 |
Correct |
6 ms |
344 KB |
Output is correct |
11 |
Correct |
3 ms |
344 KB |
Output is correct |
12 |
Correct |
15 ms |
344 KB |
Output is correct |
13 |
Correct |
20 ms |
344 KB |
Output is correct |
14 |
Correct |
17 ms |
436 KB |
Output is correct |
15 |
Correct |
5 ms |
344 KB |
Output is correct |
16 |
Correct |
6 ms |
440 KB |
Output is correct |
17 |
Correct |
5 ms |
344 KB |
Output is correct |
18 |
Correct |
8 ms |
344 KB |
Output is correct |
19 |
Correct |
8 ms |
344 KB |
Output is correct |
20 |
Correct |
5 ms |
344 KB |
Output is correct |
21 |
Correct |
5 ms |
600 KB |
Output is correct |
22 |
Correct |
3 ms |
440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
7 ms |
436 KB |
Output is correct |
10 |
Correct |
6 ms |
344 KB |
Output is correct |
11 |
Correct |
3 ms |
344 KB |
Output is correct |
12 |
Correct |
15 ms |
344 KB |
Output is correct |
13 |
Correct |
20 ms |
344 KB |
Output is correct |
14 |
Correct |
17 ms |
436 KB |
Output is correct |
15 |
Correct |
5 ms |
344 KB |
Output is correct |
16 |
Correct |
6 ms |
440 KB |
Output is correct |
17 |
Correct |
5 ms |
344 KB |
Output is correct |
18 |
Correct |
8 ms |
344 KB |
Output is correct |
19 |
Correct |
8 ms |
344 KB |
Output is correct |
20 |
Correct |
5 ms |
344 KB |
Output is correct |
21 |
Correct |
5 ms |
600 KB |
Output is correct |
22 |
Correct |
3 ms |
440 KB |
Output is correct |
23 |
Correct |
7 ms |
600 KB |
Output is correct |
24 |
Correct |
9 ms |
344 KB |
Output is correct |
25 |
Correct |
7 ms |
344 KB |
Output is correct |
26 |
Correct |
61 ms |
592 KB |
Output is correct |
27 |
Correct |
67 ms |
344 KB |
Output is correct |
28 |
Correct |
14 ms |
344 KB |
Output is correct |
29 |
Correct |
146 ms |
344 KB |
Output is correct |
30 |
Correct |
191 ms |
456 KB |
Output is correct |
31 |
Correct |
44 ms |
344 KB |
Output is correct |
32 |
Correct |
71 ms |
676 KB |
Output is correct |
33 |
Correct |
79 ms |
344 KB |
Output is correct |
34 |
Correct |
67 ms |
476 KB |
Output is correct |
35 |
Correct |
60 ms |
464 KB |
Output is correct |
36 |
Correct |
62 ms |
344 KB |
Output is correct |
37 |
Correct |
55 ms |
344 KB |
Output is correct |
38 |
Correct |
41 ms |
344 KB |
Output is correct |
39 |
Correct |
26 ms |
452 KB |
Output is correct |
40 |
Correct |
15 ms |
464 KB |
Output is correct |
41 |
Correct |
10 ms |
600 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 |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Partially correct |
0 ms |
344 KB |
Output is partially correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
24 ms |
688 KB |
Output is correct |
8 |
Correct |
18 ms |
592 KB |
Output is correct |
9 |
Correct |
18 ms |
688 KB |
Output is correct |
10 |
Partially correct |
189 ms |
432 KB |
Output is partially correct |
11 |
Partially correct |
141 ms |
344 KB |
Output is partially correct |
12 |
Correct |
36 ms |
344 KB |
Output is correct |
13 |
Incorrect |
273 ms |
592 KB |
Too many queries. |
14 |
Halted |
0 ms |
0 KB |
- |