Submission #820111

#TimeUsernameProblemLanguageResultExecution timeMemory
820111oscar1fCounting Mushrooms (IOI20_mushrooms)C++17
92.62 / 100
7 ms448 KiB
#include<bits/stdc++.h> #include "mushrooms.h" using namespace std; int nbVal,idCour,nbA,ans,taille; vector<int> listeA,listeB; vector<int> quest; int count_mushrooms(int n) { nbVal=n; idCour=1; nbA=1; listeA.push_back(0); while (idCour<nbVal) { quest.clear(); if ((int)max(listeA.size(),listeB.size())>=85 or (int)max(listeA.size(),listeB.size())<=1 or idCour==nbVal-1) { if (listeA.size()>=listeB.size()) { for (int i=0;i<(int)listeA.size();i++) { if (idCour<nbVal) { quest.push_back(listeA[i]); quest.push_back(idCour); idCour++; } } ans=use_machine(quest); if (ans%2==0) { listeA.push_back(quest.back()); } else { listeB.push_back(quest.back()); } taille=quest.size()/2; ans=(ans+1)/2; nbA+=taille-ans; } else { for (int i=0;i<(int)listeB.size();i++) { if (idCour<nbVal) { quest.push_back(listeB[i]); quest.push_back(idCour); idCour++; } } ans=use_machine(quest); if (ans%2==1) { listeA.push_back(quest.back()); } else { listeB.push_back(quest.back()); } taille=quest.size()/2; ans=(ans+1)/2; nbA+=ans; } } else { if ((int)listeA.size()>=2) { quest={listeA[0],idCour,listeA[1],idCour+1}; ans=use_machine(quest); if (ans==0) { listeA.push_back(idCour); listeA.push_back(idCour+1); nbA+=2; } if (ans==1) { listeA.push_back(idCour); listeB.push_back(idCour+1); nbA++; } if (ans==2) { listeB.push_back(idCour); listeA.push_back(idCour+1); nbA++; } if (ans==3) { listeB.push_back(idCour); listeB.push_back(idCour+1); } idCour+=2; } else { quest={listeB[0],idCour,listeB[1],idCour+1}; ans=use_machine(quest); if (ans==0) { listeB.push_back(idCour); listeB.push_back(idCour+1); } if (ans==1) { listeB.push_back(idCour); listeA.push_back(idCour+1); nbA++; } if (ans==2) { listeA.push_back(idCour); listeB.push_back(idCour+1); nbA++; } if (ans==3) { listeA.push_back(idCour); listeA.push_back(idCour+1); nbA+=2; } idCour+=2; } } } return nbA; }
#Verdict Execution timeMemoryGrader output
Fetching results...