#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
typedef vector<int> vi;
string s;
/*int use_machine(vi m){
int cont=0;
for(int i=0; i<m.size()-1; i++){
if(s[m[i]]!=s[m[i+1]]){
cont++;
}
}
return cont;
}*/
int count_mushrooms(int n) {
vi m;
int c1=1;
bool ban=true;
for(int i=0; i<n-1; i+=2){
m.clear();
m.push_back(i);
m.push_back(i+1);
if(i+2<n)m.push_back(i+2);
// cout<<i+2<<n<<endl;
int x =use_machine(m);
// cout<<x<<endl;
if(ban){
if(i+2>=n){
if(x==0)c1++;
continue;
}
if(x==0) c1+=2;
if(x==2) c1+=1;
if(x==1){
m.clear();
m.push_back(i+1);
m.push_back(i+2);
int y =use_machine(m);
if(y==1) c1++;
ban=false;
}
}else{
if(i+2>n){
if(x==1)c1++;
continue;
}
if(x==2) c1+=1;
if(x==1){
m.clear();
m.push_back(i+1);
m.push_back(i+2);
int y =use_machine(m);
if(y==1) c1++;
ban=true;
}
}
}
return c1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Answer is not correct. |
4 |
Halted |
0 ms |
0 KB |
- |