제출 #1133634

#제출 시각아이디문제언어결과실행 시간메모리
1133634alterio버섯 세기 (IOI20_mushrooms)C++20
25 / 100
26 ms632 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; int count_mushrooms(int n) { vector<int> A = {0}, B; int x = use_machine({0, 1}); int start = 2; if (x == 0) A.push_back(1); else { B.push_back(1); if (n <= 2) return A.size(); x = use_machine({0, 2}); if (x == 0) A.push_back(2); else B.push_back(2); start = 3; } for (int i = start; i < n; i += 2) { if (i + 1 < n) { if (A.size() >= 2) { x = use_machine({A[0], i, A[1], i + 1}); if (x == 0) A.push_back(i), A.push_back(i + 1); if (x == 1) A.push_back(i), B.push_back(i + 1); if (x == 2) A.push_back(i + 1), B.push_back(i); if (x == 3) B.push_back(i), B.push_back(i + 1); } else { x = use_machine({B[0], i, B[1], i + 1}); if (x == 0) B.push_back(i), B.push_back(i + 1); if (x == 1) B.push_back(i), A.push_back(i + 1); if (x == 2) B.push_back(i + 1), A.push_back(i); if (x == 3) A.push_back(i), A.push_back(i + 1); } } else { x = use_machine({0, i}); if (x == 0) A.push_back(i); else B.push_back(i); } } return A.size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...