# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
346428 | SecretK | Counting Mushrooms (IOI20_mushrooms) | C++14 | 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>
/*int count_mushrooms(int n) { 10 point
std::vector<int> m;
bool a = 0;
int ans = 1;
for (int i = 0; i < n-1; i++){
if(use_machine({i,i+1}) == 1){
if(a) a = 0;
else a = 1;
}
if(!a) ans++;
}
return ans;
}*/
int count_mushrooms(int n){
std::vector<int> m;
bool a = 0;
int ans = 1,i,t,j;
for(i = 0;i < n-2;i+=2){
if(a){
t = use_machine({i,i+1,i+2});
if(t == 1){
a = 0;
if(use_machine({j,j+1})) ans += 2;
else ans++;
}
if(t == 2){
ans++;
}
}
else{
t = use_machine({i,i+1,i+2});
if(t == 0) ans += 2;
if(t == 1){
a = 1;
if(use_machine({j,j+1}));
else ans++;
}
if(t == 2){
ans++;
}
}
}
if(i < n-1){
if(a){
if(use_machine({i,i+1})) ans++;
}
else{
if(!use_machine({i,i+1})) ans++;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |