제출 #1297432

#제출 시각아이디문제언어결과실행 시간메모리
1297432kawhiet버섯 세기 (IOI20_mushrooms)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; int count_mushrooms(int n) { int res = 1, prv = 0; int j = -1; for (int i = 2; i < n; i += 2) { if (j == -1) { int x = use_machine({0, i - 1, i}); if (x == 0) { j = i - 1; res += 2; } else if (x == 1) { if (use_machine({i - 1, i}) == 1) { j = i - 1; res++; } } else { j = i; res++; } } else { int x = use_machine({0, i - 1, j, i}); if (x == 0) { res += 2; } else if (x == 1 || x == 2) { res++; } } cout << i << ' ' << res << '\n'; } if (n % 2 == 0) { if (use_machine({0, n - 1}) == 0) { res++; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...