제출 #957375

#제출 시각아이디문제언어결과실행 시간메모리
95737512345678버섯 세기 (IOI20_mushrooms)C++17
80.14 / 100
6 ms756 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int res, a, b, m, sz; vector<int> x, y; int count_mushrooms(int n) { if (n<=282) { for (int i=1; i<n; i++) if (use_machine(vector<int> {0, i})==0) res++; return res+1; } x.push_back(0); if (use_machine(vector<int> {0, 1})==0) { a=0, b=1, m=0; x.push_back(1); if (use_machine(vector<int> {1, 2})==0) x.push_back(2); else y.push_back(2); } else if (use_machine(vector<int> {1, 2})==0) a=1, b=2, m=1, y.push_back(1), y.push_back(2); else a=0, b=2, m=0, y.push_back(1), x.push_back(2); for (int i=3; i<282; i+=2) { int tmp=use_machine(vector<int> {a, i, b, i+1}); if (m) { if (tmp==3) x.push_back(i), x.push_back(i+1); else if (tmp==2) x.push_back(i), y.push_back(i+1); else if (tmp==1) x.push_back(i+1), y.push_back(i); else y.push_back(i), y.push_back(i+1); } else { if (tmp==3) y.push_back(i), y.push_back(i+1); else if (tmp==2) y.push_back(i), x.push_back(i+1); else if (tmp==1) y.push_back(i+1), x.push_back(i); else x.push_back(i), x.push_back(i+1); } } res=x.size(); if (x.size()>=y.size()) m=0, sz=x.size()-1; else m=1, sz=y.size()-1; /* cout<<"debug x : "; for (auto z:x) cout<<z<<' '; cout<<'\n'; cout<<"debug y : "; for (auto z:y) cout<<z<<' '; cout<<'\n'; */ for (int i=283; i<n; i+=sz) { vector<int> qrs; int cnt=0; for (int j=0; j<sz; j++) { if (m) qrs.push_back(y[j]); else qrs.push_back(x[j]); if (i+j<n) qrs.push_back(i+j), cnt++; } if (m) qrs.push_back(y.back()); else qrs.push_back(x.back()); int tmp=use_machine(qrs)/2; if (m) res+=tmp; else res+=cnt-tmp; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...