Submission #1035347

#TimeUsernameProblemLanguageResultExecution timeMemory
1035347Mr_HusanboyCounting Mushrooms (IOI20_mushrooms)C++17
25 / 100
79 ms596 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define all(a) (a).begin(), (a).end() #define ff first #define ss second template<typename T> int len(T &a){return a.size();} mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int count_mushrooms(int n) { if(n < 5){ int ans = 1; for(int i = 1; i < n; i ++){ ans += use_machine({0, i}) ^ 1; } return ans; } vector<int> a = {0}, b; for(int i = 1; i < 3; i ++){ if(use_machine({0, i})){ b.push_back(i); }else a.push_back(i); } int ans = len(a); if(len(a) >= 2){ for(int i = 3; i + 1 < n; i += 2){ int c = use_machine({a[0], i, a[1], i + 1}); ans += 2 - __builtin_popcount(c); } }else{ for(int i = 3; i + 1 < n; i += 2){ int c = use_machine({b[0], i, b[1], i + 1}); ans += __builtin_popcount(c); } } if(n % 2 == 0){ ans += use_machine({0, n - 1}) ^ 1; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...