제출 #427181

#제출 시각아이디문제언어결과실행 시간메모리
427181AugustinasJucas버섯 세기 (IOI20_mushrooms)C++14
0 / 100
1 ms200 KiB
#include <bits/stdc++.h> using namespace std; #include "mushrooms.h" int count_mushrooms(int n) { if(n <= 10){ int A = 1, B = 0; for(int i = 1; i < n; i++){ int kek = use_machine({0, i}); if(kek == 0){ A++; }else{ B++; } } return A; } int ans = 1e9; int kekViename = -1; for(int i = 1; i < n; i++){ int st = 2 * i + (n - 2*i) / (i) + 1; // kuo tiksliau, tuo geriau! if(ans > st){ ans = st; kekViename = i; } } int lastTaken = 0; vector<int> A = {0}, B; int left = n-1; int answ = 1; //cout << "ieskosiu pirmuju " << kekViename << " * 2 skaiciu!" << endl; for(int i = 1; i <= kekViename * 2; i++){ int kek = use_machine({0, i}); if(kek == 0){ A.push_back(i); answ++; }else{ B.push_back(i); } left--; lastTaken = i; if((int)A.size() >= kekViename+1 || (int)B.size() >= kekViename+1){ break; } } //cout << "radau! A: "; for(auto x : A) cout << x<< " "; //cout << ". B: "; for(auto x : B) cout << x << " "; cout << endl << endl; while(true){ if(A.size() > B.size()){ //cout << "I tarpus desim A " << endl; // desim A ir i tarpus kitka vector<int> st; int ind = 1; st.push_back(A[0]); for(int i = 0; i < min(left, (int) A.size()-1); i++){ st.push_back(++lastTaken); st.push_back(A[ind++]); } int visoBuvo = min(left, (int) A.size()-1); //cout << "gaunam st: "; for(auto x : st) cout << x << " "; cout << endl; left -= min(left, (int) A.size()-1); int rz = use_machine(st); //cout << "pridedame " << visoBuvo << " - " << rz << "/2\n\n"; answ += visoBuvo - rz/2; }else{ vector<int> st; int ind = 1; st.push_back(B[0]); for(int i = 0; i < min(left, (int) B.size()-1); i++){ st.push_back(++lastTaken); st.push_back(A[ind++]); } left -= min(left, (int) B.size()-1); int rz = use_machine(st); answ += rz/2; } if(left == 0) break; } return answ; }
#Verdict Execution timeMemoryGrader output
Fetching results...