제출 #1194648

#제출 시각아이디문제언어결과실행 시간메모리
1194648simona1230버섯 세기 (IOI20_mushrooms)C++20
80.71 / 100
3 ms464 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #define pb push_back using namespace std; const int x=100; vector<int> a,b,v; int count_mushrooms(int n) { int c; if(n==2) { c=use_machine({0,1}); if(c==1)return 1; return 2; } int ans=1; a.push_back(0); c=use_machine({0,1,2}); if(c==2) { a.push_back(2); b.push_back(1); ans++; } if(c==0) { a.push_back(1); a.push_back(2); ans+=2; } if(c==1) { c=use_machine({0,1}); if(c==1)b.pb(1); else ans++,a.pb(1); b.push_back(2); } int i=3; while(i<n) { vector<int> h; if(a.size()>b.size()) { for(int j=0;j<a.size();j++) { h.push_back(a[j]); if(i==n)break; h.push_back(i++); } c=use_machine(h); ans+=(h.size()-1)/2-c/2; if(h.size()%2==0) { if(c%2==0)ans++,a.pb(h[h.size()-1]); else b.pb(h[h.size()-1]); } } else { for(int j=0;j<b.size();j++) { h.push_back(b[j]); if(i==n)break; h.push_back(i++); } c=use_machine(h); ans+=c/2; if(h.size()%2==0) { if(c%2==0)b.pb(h[h.size()-1]); else ans++,a.pb(h[h.size()-1]); } } /*for(int j=0;j<h.size();j++) cout<<h[j]<<" "; cout<<endl;*/ } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...