제출 #423864

#제출 시각아이디문제언어결과실행 시간메모리
423864Mohammed_Atalah버섯 세기 (IOI20_mushrooms)C++17
0 / 100
1 ms200 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> indices; for (int i = 0; i < n; i++) { indices.push_back(i); } if (use_machine(indices) == 0) { return n; } int bs = 0; int as = 0; vector<int> a; vector<int> b; int last_index; for (int i = 1; i < n; i += 2) { if (a.size() == 20 || b.size() == 20) { last_index = i + 2; break; } if (i + 1 == n) { std::vector<int> v; v.push_back(0); v.push_back(i); if (use_machine(v) == 1) { bs++; } else { as++; } continue; } std::vector<int> v; v.push_back(i); v.push_back(0); v.push_back(i + 1); int r = use_machine(v); bs += r; as += 2 - r; if (r == 2) { b.push_back(i); b.push_back(i + 1); } else if (r == 0) { a.push_back(i); a.push_back(i + 1); } } if (a.size() != 20 && b.size() != 20) { return n - bs; } int remain = n - last_index; if (a.size() == 20) { while (remain > 0) { if (remain >= 19) { vector<int> v; v.push_back(a[0]); for (int i = 1; i < 20; i++) { v.push_back(last_index); v.push_back(a[i]); last_index++; } bs += use_machine(v) / 2; remain -= 19; } else { vector<int> v; v.push_back(a[0]); for (int i = 1; i < remain; i++) { v.push_back(last_index); v.push_back(a[i]); last_index++; } bs += use_machine(v) / 2; remain -= remain; } } return n - bs; } else { while (remain > 0) { if (remain >= 19) { vector<int> v; v.push_back(b[0]); for (int i = 1; i < 20; i++) { v.push_back(last_index); v.push_back(b[i]); last_index++; } as += use_machine(v) / 2; remain -= 19; } else { vector<int> v; v.push_back(b[0]); for (int i = 1; i < remain; i++) { v.push_back(last_index); v.push_back(b[i]); last_index++; } as += use_machine(v) / 2; remain -= remain; } } return as; } }
#Verdict Execution timeMemoryGrader output
Fetching results...