Submission #1204123

#TimeUsernameProblemLanguageResultExecution timeMemory
1204123gohchingjaykMinerals (JOI19_minerals)C++20
40 / 100
15 ms3992 KiB
#include "minerals.h" #include "bits/stdc++.h" using ll = long long; using namespace std; #define int ll int indices[2*43000 + 5]; map<int, vector<int>> pairs; int N; void dnc(int marker, int nPairs, vector<int> &nextIndices) { if (nPairs == 0) return; if (nPairs == 1) return; vector<int> next0{}; vector<int> next1{}; int targetPairs = nPairs / 2; //std::cerr << marker << ' ' << nPairs << '\n'; for (int i : nextIndices) { int uniques = Query(i); if (uniques > targetPairs) { Query(i); indices[i] = marker * 2 + 1; next1.emplace_back(i); } } int last = 0; for (int i : nextIndices) { if (indices[i] == marker) { last = Query(i); indices[i] = marker * 2; next0.emplace_back(i); } } assert(last == 0); dnc(marker * 2, targetPairs, next0); dnc(marker * 2 + 1, nPairs - targetPairs, next1); } void Solve(signed V) { N = V; //std::cerr << "solving" <<'\n'; fill(indices, indices + 2 * N + 5, 1); pairs.clear(); vector<int> next; for (int i = 1; i <= 2 * N; ++i) next.emplace_back(i); dnc(1, N, next); for (int i = 1; i <= 2 * N; ++i) pairs[indices[i]].emplace_back(i); for (auto &x : pairs) { Answer(x.second[0], x.second[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...