Submission #1064807

#TimeUsernameProblemLanguageResultExecution timeMemory
1064807thatsgonzalezCounting Mushrooms (IOI20_mushrooms)C++14
25 / 100
74 ms596 KiB
#include "mushrooms.h" int count_mushrooms(int n) { int ans = 1; int b = -1; for(int i = 1; i<n; i+=2){ if(i==n-1){ int res = use_machine({0,i}); if(!res) ans++; return ans; } int res = use_machine({0,i,i+1}); if(res == 2) ans++; else if(res == 0) ans+=2; else{ if(use_machine({0,i})){ b = i+1; } else{ ans++; b = i+1; } break; } } int a = -1; for(int i = b+1; i<n and b>=0; i+=2){ if(i==n-1){ int res = use_machine({0,i}); if(!res) ans++; return ans; } int res = use_machine({b,i,i+1}); if(res == 2) ans++; else if(res == 1){ if(use_machine({b,i})){ ans+=2; a = i+1; } else{ ans++; a = i+1; } break; } } for(int i = a+1; i<n and a>=0; i+=2){ if(i==n-1){ int res = use_machine({0,i}); if(!res) ans++; return ans; } int res = use_machine({0,i,a,i+1}); if(res == 1 || res == 2){ ans++; } else if(res == 0) ans+=2; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...