# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
355488 | juggernaut | Counting Mushrooms (IOI20_mushrooms) | C++14 | 13 ms | 516 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "mushrooms.h"
#ifndef EVAL
#include "stub.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
const int rt = 170;
int count_mushrooms(int n) {
int ans = 1;
vector<int> A, B;
A.push_back(0);
if(n <= 220){
for(int i=1;i<n;i++){
vector<int> tmp = {0,i};
int t = use_machine(tmp);
if(t == 0)A.push_back(i), ans++;
else B.push_back(i);
}return ans;
}
for(int i=1;i<4;i++){
vector<int> tmp = {0,i};
int t = use_machine(tmp);
if(t == 0)A.push_back(i), ans++;
else B.push_back(i);
}
for(int i=4;i<rt;i+=2){
if(A.size() >= B.size()){
vector<int> tmp = {A[0], i, A[1], i+1};
int t = use_machine(tmp);
if(t&1){
B.push_back(i+1);
}else {
A.push_back(i+1);
ans++;
}
if(t&2){
B.push_back(i);
}else {
A.push_back(i);
ans++;
}
}else {
vector<int> tmp = {B[0], i, B[1], i+1};
int t = use_machine(tmp);
if(t&1){
A.push_back(i+1);
ans++;
}else {
B.push_back(i+1);
}
if(t&2){
A.push_back(i);
ans++;
}else {
B.push_back(i);
}
}
}
for(int i=rt; i<n; i++){
if(A.size() >= B.size()){
vector<int> tmp;
for(int j=0;j<(int)A.size();j++){
if(i == n)break;
tmp.push_back(A[j]);
tmp.push_back(i++);
}int t = use_machine(tmp);
if(t%2==1){
B.push_back(tmp.back());
t ^= 1;
}else A.push_back(tmp.back()),ans++;
int sz = (tmp.size()-1)/2;
ans += (sz*2-t)/2;
}else {
vector<int> tmp;
for(int j=0;j<(int)B.size();j++){
if(i == n)break;
tmp.push_back(B[j]);
tmp.push_back(i++);
}int t = use_machine(tmp);
if(t%2==1){
A.push_back(tmp.back());
t ^= 1;
ans++;
}else B.push_back(tmp.back());
ans += (t)/2;
}
i--;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |