#include"mushrooms.h"
#include<bits/stdc++.h>
#include"stub.cpp"
using namespace std;
int count_mushrooms(int n){
vector<int>a,b,id;
int i=1,res=1,j;
for(;i<n;i++)id.push_back(i);
//shuffle(id.begin(),id.end(),default_random_engine(chrono::system_clock::now().time_since_epoch().count()));
i=1;
a.push_back(0);
while(i<min(n,3)){
if(use_machine({0,id[i-1]}))b.push_back(id[i-1]);
else a.push_back(id[i-1]),res++;
i++;
}
while(i+1<min(80,n)){
if(a.size()>b.size()){
j=use_machine({a[0],id[i-1],a[1],id[i]});
if(j&1)b.push_back(id[i]);
else a.push_back(id[i]),res++;
if(j&2)b.push_back(id[i-1]);
else a.push_back(id[i-1]),res++;
}else{
j=use_machine({b[0],id[i-1],b[1],id[i]});
if(j&1)a.push_back(id[i]),res++;
else b.push_back(id[i]);
if(j&2)a.push_back(id[i-1]),res++;
else b.push_back(id[i-1]);
}
i+=2;
}
while(i<n){
if(a.size()>b.size()){
vector<int>v;
for(j=0;j<a.size()&&i+j<n;j++){
v.push_back(a[j]);
v.push_back(id[i+j-1]);
}
i+=j;
j=use_machine(v);
if(j&1)b.push_back(v.back());
else a.push_back(v.back());
j++;
j>>=1;
res+=(((int(v.size()))>>1))-j;
}else{
vector<int>v;
for(j=0;j<b.size()&&i+j<n;j++){
v.push_back(b[j]);
v.push_back(id[i+j-1]);
}
i+=j;
j=use_machine(v);
if(j&1)a.push_back(v.back());
else b.push_back(v.back());
j++;
j>>=1;
res+=j;
}
}
return res;
}
Compilation message
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(j=0;j<a.size()&&i+j<n;j++){
| ~^~~~~~~~~
mushrooms.cpp:49:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(j=0;j<b.size()&&i+j<n;j++){
| ~^~~~~~~~~
/tmp/cczylRdz.o: In function `use_machine(std::vector<int, std::allocator<int> >)':
stub.cpp:(.text+0x200): multiple definition of `use_machine(std::vector<int, std::allocator<int> >)'
/tmp/cctSrzJo.o:mushrooms.cpp:(.text+0x200): first defined here
/tmp/cczylRdz.o: In function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cctSrzJo.o:mushrooms.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status