Submission #674004

#TimeUsernameProblemLanguageResultExecution timeMemory
674004peijarSuper Dango Maker (JOI22_dango3)C++17
22 / 100
768 ms588 KiB
#include "dango3.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int randint(int lb, int ub) { return uniform_int_distribution<int>(lb, ub)(rng); } void Solve(int nbCouleurs, int parCouleur) { vector<vector<int>> sol(parCouleur); vector<int> bef; int tot = nbCouleurs * parCouleur; vector<bool> killed(tot); for (int iCouleur = 0; iCouleur < nbCouleurs; ++iCouleur) { vector<int> indicesRestants; for (int i = 0; i < tot; ++i) if (!killed[i]) indicesRestants.push_back(i); shuffle(indicesRestants.begin(), indicesRestants.end(), rng); int lo = 0, up = indicesRestants.size() - 1; while (lo < up) { int mid = (lo + up) / 2; vector<int> toQuery = bef; for (int i = 0; i <= mid; ++i) toQuery.push_back(indicesRestants[i] + 1); if (Query(toQuery) >= 1) up = mid; else lo = mid + 1; } vector<int> almostAll = bef; for (int i = 0; i < lo; ++i) almostAll.push_back(indicesRestants[i] + 1); int prv = lo; killed[indicesRestants[prv]] = true; sol[0].push_back(indicesRestants[prv] + 1); for (int iEl = 1; iEl < parCouleur; ++iEl) { lo = prv + 1, up = (int)indicesRestants.size() - 1; while (lo < up) { int mid = (lo + up) / 2; vector<int> toQuery = almostAll; for (int i = prv + 1; i <= mid; ++i) toQuery.push_back(indicesRestants[i] + 1); if (Query(toQuery) >= 1) up = mid; else lo = mid + 1; } killed[indicesRestants[lo]] = true; sol[iEl].push_back(indicesRestants[lo] + 1); prv = lo; } bef.push_back(indicesRestants[prv] + 1); } for (auto &s : sol) Answer(s); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...