제출 #1182681

#제출 시각아이디문제언어결과실행 시간메모리
1182681lalig777Counting Mushrooms (IOI20_mushrooms)C++20
80.71 / 100
3 ms464 KiB
#include <iostream> #include <vector> #include <algorithm> #include "mushrooms.h" using namespace std; int count_mushrooms(int n){ vector<int>a; vector<int>b; vector<int>x; int counta=1, i=1; a.push_back(0); while (i<n){ x.clear(); if (a.size()>b.size()){ for (int j=0; j<a.size(); j++){ if (j+i>=n) break; x.push_back(a[j]); x.push_back(j+i); }i+=a.size(); int y=use_machine(x); if (y%2==0){ a.push_back(x[x.size()-1]); counta++; }else{ b.push_back(x[x.size()-1]); }counta+=(x.size()/2-1-y/2); }else{ for (int j=0; j<b.size(); j++){ if (j+i>=n) break; x.push_back(b[j]); x.push_back(j+i); }i+=b.size(); int y=use_machine(x); if (y%2==0){ b.push_back(x[x.size()-1]); }else{ a.push_back(x[x.size()-1]); counta++; }counta+=(y/2); } }return counta; }
#Verdict Execution timeMemoryGrader output
Fetching results...