제출 #701689

#제출 시각아이디문제언어결과실행 시간메모리
701689grossly_overconfident버섯 세기 (IOI20_mushrooms)C++17
0 / 100
2 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; /* int use_machine(vector<int> v){ int count = 0; vector<int> shrooms = { 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2 }; for (int i = 1; i < v.size(); ++i){ if (shrooms[v[i]] != shrooms[v[i - 1]]){ count++; } } return count; } */ int count_mushrooms(int n) { if (n < 220){ int a = 1; for (int i = 1; i < n; ++i){ a += 1 - use_machine({ 0, i }); } return a; } int asize = 1; int bsize = 0; vector<int> a(1, 0); vector<int> b; if (use_machine({ 0, 1 }) == 1){ b.push_back(1); bsize++; } else{ a.push_back(1); asize++; } if (use_machine({ 0, 2 }) == 1){ b.push_back(2); bsize++; } else{ a.push_back(2); asize++; } for (int i = 3; i <= 150; i += 2){ if (asize > bsize){ int h = use_machine({ i, a[0], i + 1, a[1]}); cout << i << " " << a[0] << " " << i + 1 << " " << a[1] << " :: " << h << " :: a" << endl; if (h == 0){ asize += 2; a.push_back(i); a.push_back(i + 1); } else if (h == 3){ bsize += 2; b.push_back(i); b.push_back(i + 1); } else{ bsize += 1; asize += 1; if (h == 1){ b.push_back(i); a.push_back(i + 1); } else{ a.push_back(i); b.push_back(i + 1); } } } else { int h = use_machine({ i, b[0], i + 1, b[1] }); cout << i << " " << b[0] << " " << i + 1 << " " << b[1] << " :: " << h << " :: b" << endl; if (h == 0){ bsize += 2; b.push_back(i); b.push_back(i + 1); } else if (h == 3){ asize += 2; a.push_back(i); a.push_back(i + 1); } else{ bsize += 1; asize += 1; if (h == 1){ a.push_back(i); b.push_back(i + 1); } else{ b.push_back(i); a.push_back(i + 1); } } } } for (auto u : a){ cout << u << " "; } cout << endl << endl; for (auto u : b){ cout << u << " "; } int i = 151; int tally = asize; while (true){ if (a.size() < b.size()){ vector<int> p; int w = i; for (int j = 0; j < bsize; ++j){ p.push_back(i); p.push_back(b[j]); i++; if (i == n){ break; } } int h = use_machine(p); if (h % 2 == 0){ b.push_back(w); tally += h / 2; bsize++; } else{ a.push_back(w); tally++; asize++; tally += (h - 1) / 2; } if (i == n){ return tally; } } else{ vector<int> p; int w = i; for (int j = 0; j < asize; ++j){ p.push_back(i); p.push_back(a[j]); i++; if (i == n){ break; } } int h = use_machine(p); if (h % 2 == 0){ a.push_back(w); asize++; tally++; tally += (i - w) - (h / 2); } else{ b.push_back(w); bsize++; tally += (i - w) - ((h - 1) / 2); } if (i == n){ return tally - 2; } } if (i == n){ return tally - 2; } } } /* int main(){ cout << count_mushrooms(302) - 2; return 0; } */
#Verdict Execution timeMemoryGrader output
Fetching results...