# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
304855 | 2020-09-22T02:57:41 Z | llaki | 버섯 세기 (IOI20_mushrooms) | C++17 | 3 ms | 384 KB |
#include <math.h> #include <iostream> #include <vector> #include "mushrooms.h" int count_mushrooms(int n) { if (n <= 226) { std::vector<int> m; int ans = 1; for (int i = 1; i < n; i++) { m = {0, i}; int res = use_machine(m); if (res == 0) ans++; } return ans; } int k = (int) (sqrt(n / 2)); std::vector<int> ones, zeroes; int known[20001]; for (int i = 0; i <= 20000; i++) { known[i] = 0; } for (int q = 0; ; q++) { if (1 + q * k >= n) break; std::vector<int> query; query.push_back(0); for (int i = 1; i <= k; i++) { int num = i + q * k; if (num >= n) break; query.push_back(num); } int res = use_machine(query); int largest = query[query.size() - 1]; if (res % 2 == 0) { zeroes.push_back(largest); } else { ones.push_back(largest); } known[largest] = 1; } int countZeroes = 1 + zeroes.size(); std::vector<int> unknown; for (int i = 1; i < n; i++) { if (known[i] != 1) { unknown.push_back(i); } } std::vector<int> indices = (ones.size() > zeroes.size() ? ones : zeroes); bool isOne = ones.size() > zeroes.size(); int s = indices.size(); for (int i = 0; i < unknown.size(); i++) { std::vector<int> query; int u = 0; for (int j = 0; j < s && i + j < unknown.size(); j++) { query.push_back(unknown[i + j]); query.push_back(indices[j]); u++; } if (query.size() < 2) break; int res = use_machine(query); res =+ res % 2; if (isOne) { countZeroes += res / 2; } else { countZeroes += u - res / 2; } i = i + s - 1; } return countZeroes; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 256 KB | Output is correct |
6 | Incorrect | 3 ms | 384 KB | Answer is not correct. |
7 | Halted | 0 ms | 0 KB | - |