Submission #1047291

#TimeUsernameProblemLanguageResultExecution timeMemory
1047291nightfalCounting Mushrooms (IOI20_mushrooms)C++17
25 / 100
70 ms596 KiB
#include <vector> #include <iostream> #include <tuple> using namespace std; int use_machine(std::vector<int> x); std::pair<int,int> count(int n, std::vector<int> &v) { int numV=0, numW=0; for(int i=3; i+1<n; i+=2) { int result = use_machine({v[0],i,v[1],i+1}); if (result%2) numW++; else numV++; if (result/2) numW++; else numV++; } if (n%2==0) { if(use_machine({v[0],n-1})) numW++; else numV++; } return {numV,numW}; } int count_mushrooms(int n) { vector<int> a, b; a.push_back(0); int numA=0, numB=0; for(int i=1; i<min(3,n); i++) if (use_machine({0,i})) b.push_back(i); else a.push_back(i); if (n<=3) return a.size(); if (a.size()>=2) tie(numA,numB) = count(n,a); else tie(numB,numA) = count(n,b); numA += a.size(); numB += b.size(); return numA; }
#Verdict Execution timeMemoryGrader output
Fetching results...