#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2e4;
const int SQ = 5000;
int N;
int query(vector<int> V)
{
return use_machine(V);
}
int count_mushrooms(int _N)
{
N=_N;
vector<int> A, B;
A.push_back(0);
int p, ans=0;
for(p=1; p<N && A.size()<=SQ && B.size()<=SQ; p++)
{
if(query({0, p})) B.push_back(p);
else A.push_back(p);
}
ans=A.size();
//printf("%d %d\n", p, A.size());
if(A.size()>=SQ)
{
while(p<N)
{
int i, j;
vector<int> V;
for(j=0; p<N && j<SQ; p++, j++)
{
V.push_back(A[j]);
V.push_back(p);
}
V.push_back(A[j]);
ans+=j-query(V)/2;
}
}
else
{
while(p<N)
{
int i, j;
vector<int> V;
for(j=0; p<N && j<SQ; p++, j++)
{
V.push_back(B[j]);
V.push_back(p);
}
V.push_back(B[j]);
ans+=query(V)/2;
}
}
return ans;
}
Compilation message
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:40:8: warning: unused variable 'i' [-Wunused-variable]
40 | int i, j;
| ^
mushrooms.cpp:55:8: warning: unused variable 'i' [-Wunused-variable]
55 | int i, j;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Partially correct |
19 ms |
384 KB |
Output is partially correct |
7 |
Partially correct |
65 ms |
560 KB |
Output is partially correct |
8 |
Partially correct |
79 ms |
520 KB |
Output is partially correct |
9 |
Partially correct |
56 ms |
572 KB |
Output is partially correct |
10 |
Partially correct |
70 ms |
504 KB |
Output is partially correct |
11 |
Partially correct |
126 ms |
664 KB |
Output is partially correct |
12 |
Partially correct |
81 ms |
616 KB |
Output is partially correct |
13 |
Partially correct |
54 ms |
544 KB |
Output is partially correct |
14 |
Partially correct |
99 ms |
448 KB |
Output is partially correct |
15 |
Partially correct |
90 ms |
588 KB |
Output is partially correct |
16 |
Partially correct |
114 ms |
572 KB |
Output is partially correct |
17 |
Partially correct |
63 ms |
424 KB |
Output is partially correct |
18 |
Partially correct |
68 ms |
524 KB |
Output is partially correct |
19 |
Partially correct |
70 ms |
584 KB |
Output is partially correct |
20 |
Partially correct |
71 ms |
544 KB |
Output is partially correct |
21 |
Partially correct |
72 ms |
544 KB |
Output is partially correct |
22 |
Partially correct |
68 ms |
588 KB |
Output is partially correct |
23 |
Partially correct |
62 ms |
568 KB |
Output is partially correct |
24 |
Partially correct |
78 ms |
448 KB |
Output is partially correct |
25 |
Incorrect |
107 ms |
572 KB |
Answer is not correct. |
26 |
Halted |
0 ms |
0 KB |
- |