Submission #1034460

#TimeUsernameProblemLanguageResultExecution timeMemory
1034460BlagojMinerals (JOI19_minerals)C++17
100 / 100
32 ms3928 KiB
#include <bits/stdc++.h> #include "minerals.h" using namespace std; int val; bool get(int x) { int otherVal = Query(x); swap(val, otherVal); return val != otherVal; } void solve(vector<int> l, vector<int> r, int t) { int sz = l.size(); if (sz == 1) { Answer(l[0], r[0]); return; } vector<int> l1, l2, r1, r2; int mid = (int) (sz * (0.4)); for (int i = 0; i <= mid; i++) { get(l[i]); l1.push_back(l[i]); } for (int i = mid + 1; i < sz; i++) r1.push_back(l[i]); for (int i = 0; i < sz; i++) { if (l1.size() == l2.size()) r2.push_back(r[i]); else if (r1.size() == r2.size()) l2.push_back(r[i]); else if (get(r[i]) == t) l2.push_back(r[i]); else r2.push_back(r[i]); } solve(l1, l2, !t); solve(r1, r2, t); } void Solve(int N) { vector<int> l, r; for (int i = 1; i <= 2 * N; i++) { if (get(i)) l.push_back(i); else r.push_back(i); } solve(l, r, 1); }
#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...