Submission #699793

#TimeUsernameProblemLanguageResultExecution timeMemory
699793grossly_overconfidentCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
3 ms308 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { if (n < 220){ int a = 1; for (int i = 1; i < n; ++i){ a += 1 - use_machine({ 0, i }); } return a; } int asize = 0; int bsize = 0; vector<int> a(1, 0); vector<int> b; if (use_machine({ 0, 1 }) == 1){ b.push_back(1); bsize++; } else{ a.push_back(1); asize++; } if (use_machine({ 0, 2 }) == 1){ b.push_back(2); bsize++; } else{ a.push_back(2); asize++; } for (int i = 3; i <= 150; i += 2){ if (a.size() > b.size()){ int h = use_machine({ i, a[0], i + 1, a[1]}); if (h % 2){ a.push_back(i); asize++; } else{ b.push_back(i); bsize++; } if (h < 2){ a.push_back(i + 1); asize++; } else{ b.push_back(i + 1); bsize++; } } else{ int h = use_machine({ i, b[0], i + 1, b[1]}); if (h % 2){ b.push_back(i); bsize++; } else{ a.push_back(i); asize++; } if (h < 2){ b.push_back(i + 1); bsize++; } else{ a.push_back(i + 1); asize++; } } } int i = 151; int tally = a.size(); while (true){ if (a.size() < b.size()){ vector<int> p; int w = i; for (int j = 0; j < bsize; ++j){ p.push_back(i); p.push_back(b[j]); i++; if (i == n){ break; } } int h = use_machine(p); if (h % 2 == 0){ b.push_back(w); tally += h / 2; bsize++; } else{ a.push_back(w); tally++; asize++; tally += (h - 1) / 2; } if (i == n){ return tally; } } else{ vector<int> p; int w = i; for (int j = 0; j < asize; ++j){ p.push_back(i); p.push_back(a[j]); i++; if (i == n){ break; } } int h = use_machine(p); if (h % 2 == 0){ a.push_back(w); asize++; tally++; tally += (i - w) - (h / 2); } else{ b.push_back(w); bsize++; tally += (i - w) - ((h - 1) / 2); } if (i == n){ return tally; } } if (i == n){ return tally; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...