Submission #1293353

#TimeUsernameProblemLanguageResultExecution timeMemory
1293353SofiatpcCounting Mushrooms (IOI20_mushrooms)C++20
25 / 100
29 ms400 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define sz(v) (int)v.size() int count_mushrooms(int n) { int tam = 3; vector<int> a = {0}, b; int lst = 0; for (int i = 1; i < n; i++){ vector<int> aux = {0,i}; if(use_machine(aux) == 0)a.push_back(i); else b.push_back(i); lst = i; if(sz(a) == tam || sz(b) == tam)break; } if(lst+1 == n)return sz(a); vector<int> aux; int pt = 0, ans = sz(a); for(int i = lst+1; i <= n; i++){ if(sz(a) == tam)aux.push_back(a[pt]); else aux.push_back(b[pt]); pt++; if(pt == tam || i == n){ if(sz(aux) == 1)break; if(sz(a) == tam)ans += sz(aux) - pt - use_machine(aux)/2; else ans += use_machine(aux)/2; aux.clear(); if(sz(a) == tam)aux.push_back(a[0]); else aux.push_back(b[0]); pt = 1; } if(i == n)break; aux.push_back(i); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...