제출 #720708

#제출 시각아이디문제언어결과실행 시간메모리
720708nguyentunglam버섯 세기 (IOI20_mushrooms)C++17
80.43 / 100
10 ms316 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; int a[20010]; vector<int> A, B; int count_mushrooms(int n) { if (n == 2) return 1 + (use_machine({0, 1}) == 0); a[1] = use_machine({0, 1}); a[2] = use_machine({0, 2}); int x, y, type = 0; if (a[1] + a[2] == 2) { type = 1; x = 1; y = 2; } else { type = 0; if (a[1] == 0) x = 0, y = 1; else x = 0, y = 2; } int T = min((int)sqrt(n) * 2, n); int ed = 2; for(int i = 4; i < T; i += 2) { int tmp = use_machine({x, i - 1, y, i}); if (tmp / 2 > 0) a[i - 1] = type ^ 1; else a[i - 1] = type; if (tmp % 2) a[i] = type ^ 1; else a[i] = type; ed = i; } for(int i = 0; i <= ed; i++) { if (!a[i]) A.push_back(i); else B.push_back(i); } bool ok = 0; int tmp = 0; if (A.size() < B.size()) swap(A, B), ok = 1; int sz = A.size(), cnt = 0; for(int i = ed + 1; i < n; i += sz) { vector<int> ask; for(int j = i; j < n && j < i + sz; j++) { ask.push_back(A[j - i]); ask.push_back(j); cnt++; } tmp += (use_machine(ask) + 1) / 2; } if (!ok) return A.size() + cnt - tmp; return B.size() + tmp; }
#Verdict Execution timeMemoryGrader output
Fetching results...