# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
346059 | Chayanin_K | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 ms | 384 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"
#include <bits/stdc++.h>
using namespace std;
int count_mushrooms(int n) {
vector <int> A, B, send;
int res, nowi = 1, cnta = 1, cnt = 0;
A.push_back(0);
while(nowi < n){
if(A.size() >= B.size()){
cnt = 0;
send.clear();
for(int i = 0; i < A.size() && nowi < n; i++){
send.push_back(A[i]);
send.push_back(nowi);
nowi++;
cnt++;
}
res = use_machine(send);
if(res%2==1){
B.push_back(nowi-1);
}
else{
cnta += cnt - ((res+1) / 2);
A.push_back(nowi-1);
}
}
else{
send.clear();
for(int i = 0; i < B.size() && nowi < n; i++){
send.push_back(B[i]);
send.push_back(nowi);
nowi++;
}
res = use_machine(send);
if(res%2==1){
A.push_back(nowi-1);
cnta += (res+1) / 2;
}
else{
B.push_back(nowi-1);
}
}
}
return cnta;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |