Submission #546841

#TimeUsernameProblemLanguageResultExecution timeMemory
546841LucaDantasCounting Mushrooms (IOI20_mushrooms)C++17
92.24 / 100
10 ms516 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; constexpr int repeticoes = 70; vector<int> color[2]; int count_mushrooms(int N) { int cnt[2]{}; color[0] = {0}; vector<int> unknown(N-1); iota(unknown.begin(), unknown.end(), 1); bool foi = 0; while(unknown.size()) { int usar = color[1].size() > color[0].size(); // escolho o grupo que tem mais gente pra usar int sz = color[usar].size(); if(sz == 2 && !foi) { // pego alguns caras q dao pra escolher duas vezes foi = 1; for(int sla = 0; sla < repeticoes && unknown.size(); sla++) { vector<int> qr; for(int i = 0; i < sz && unknown.size(); i++, unknown.pop_back()) qr.push_back(color[usar][i]), qr.push_back(unknown.back()); int resp = use_machine(qr); color[usar ^ (resp&1)].push_back(qr.back()); if(qr.size() < 4) continue; resp >>= 1; color[usar ^ (resp&1)].push_back(qr[1]); } continue; } vector<int> qr; for(int i = 0; i < sz && unknown.size(); i++, unknown.pop_back()) qr.push_back(color[usar][i]), qr.push_back(unknown.back()); int resp = use_machine(qr); color[usar ^ (resp&1)].push_back(qr.back()); cnt[usar^1] += resp/2; cnt[usar] += (qr.size() / 2 - 1) - resp/2; } return cnt[0] + color[0].size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...