#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
int count_mushrooms(int n) {
vector<int> A, B;
A.pb(0);
for(int i = 1; i < n; i++) {
if(use_machine({0,i}) == 0) A.pb(i);
else B.pb(i);
if(sz(A) >= 100 or sz(B) >= 100) break;
}
int use = 0;
if(sz(A) < sz(B)) use = 1;
int ans = sz(A);
for(int i = sz(A) + sz(B); i < n; i+=100) {
if(use == 0) {
vector<int> q;
for(int j = i; j < min(n,i+100); i++)
q.pb(A[j-i]), q.pb(j);
int x = use_machine(q);
x = sz(q) - 1 - x; // número de posições que são iguais
ans += (x+1)/2;
}
else {
vector<int> q;
for(int j = i; j < min(n,i+100); i++)
q.pb(B[j-i]), q.pb(j);
int x = use_machine(q);
// número de posições que são diferentes
ans += (x+1)/2;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
Runtime error |
1 ms |
980 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |