제출 #542430

#제출 시각아이디문제언어결과실행 시간메모리
542430two_sidesMinerals (JOI19_minerals)C++17
100 / 100
61 ms3540 KiB
#include <bits/stdc++.h> #include "minerals.h" using namespace std; bool query(int x) { static int last = 0; int cur = Query(x); bool ans = cur != last; last = cur; return ans; } void solve(vector<int> l, vector<int> r, bool fill) { int n = (int) l.size(), m = ceil(n * 0.36); if (fill) { m = n - m; } if (n == 1) { Answer(l[0], r[0]); return; } if (fill) { for (int i = n - 1; i >= m; --i) { query(l[i]); } } else { for (int i = 0; i < m; ++i) { query(l[i]); } } vector<int> left, right; random_shuffle(r.begin(), r.end()); for (auto i : r) { if ((int) left.size() == m) { right.push_back(i); } else if ((int) right.size() == n - m) { left.push_back(i); } else if (query(i)) { right.push_back(i); } else { left.push_back(i); } } solve(vector<int>(l.begin(), l.begin() + m), left, true); solve(vector<int>(l.begin() + m, l.end()), right, false); } void Solve(int n) { vector<int> l, r; for (int i = 1; i <= n * 2; ++i) { if (query(i) == 1) { l.push_back(i); } else { r.push_back(i); } } solve(l, r, true); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...