Submission #927605

#TimeUsernameProblemLanguageResultExecution timeMemory
927605RifalCounting Mushrooms (IOI20_mushrooms)C++14
25 / 100
84 ms596 KiB
#include <bits/stdc++.h> #include "mushrooms.h" #define endl '\n' using namespace std; int count_mushrooms(int n) { vector<int> A, B; A.push_back(0); vector<int> cur; cur.push_back(0); cur.push_back(1); int num = use_machine(cur); if(num == 0) A.push_back(1); else B.push_back(1); if(n == 2) return A.size(); cur.clear(); cur.push_back(0); cur.push_back(2); num = use_machine(cur); if(num == 0) A.push_back(2); else B.push_back(2); int j = 3; int ans = 0; while(n-j > 1) { cur.clear(); if(A.size() >= 2) { cur.push_back(A[0]); cur.push_back(j); j++; cur.push_back(A[1]); cur.push_back(j); j++; } else { cur.push_back(B[0]); cur.push_back(j); j++; cur.push_back(B[1]); cur.push_back(j); j++; } int num = use_machine(cur); if(A.size() >= 2) { //cout << num << 'a' << endl; if(num == 0) ans += 2; else if(num == 1) ans++; else if(num == 2) ans++; //cout << ans << 'z' << endl; } else { // cout << num << 'b' << endl; if(num == 3) ans += 2; else if(num == 1) ans++; else if(num == 2) ans++; //cout << ans << 'z' << endl; } } if(n-j == 1) { cur.clear(); cur.push_back(0); cur.push_back(j); int num = use_machine(cur); if(num == 0) ans++; } return A.size()+ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...