제출 #825263

#제출 시각아이디문제언어결과실행 시간메모리
825263benjaminkleyn버섯 세기 (IOI20_mushrooms)C++17
25 / 100
88 ms256 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { int A = 1, cnt = 0; int i = 0; for (; i + 4 < n; i += 4) { int x = use_machine({i+0, i+1, i+2, i+3, i+4}); if (x == 0) cnt += (A ? 4 : 0); else if (x == 1) { int y = use_machine({i+0, i+3, i+1, i+4, i+2}); if (y == 1) cnt += (A ? 1 : 3); else if (y == 2) cnt += (A ? 4 : 0); else if (y == 3) cnt += 2; else if (y == 4) cnt += (A ? 3 : 1); } else if (x == 2) { int y = use_machine({i+1, i+0, i+2, i+4, i+3}); if (y <= 2) cnt += (A ? 3 : 1); else if (y == 3) cnt += 2; else if (y == 4) cnt += (A ? 1 : 3); } else if (x == 3) { int y = use_machine({i+3, i+2, i+0, i+4, i+1}); if (y == 2 || y == 3) cnt += 2; else if (y == 4 || y == 1) cnt += (A ? 3 : 1); } else if (x == 4) cnt += 2; A ^= (x % 2); } cnt += A; for (int j = i + 1; j < n; j++) cnt += 1 - use_machine({0, j}); return cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...