This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
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) {
int lo = 0, up = tot - 1;
while (lo < up) {
int mid = (lo + up) / 2;
vector<int> toQuery = bef;
for (int i = 0; i <= mid; ++i)
if (!killed[i])
toQuery.push_back(i + 1);
if (Query(toQuery) >= 1)
up = mid;
else
lo = mid + 1;
}
vector<int> almostAll = bef;
for (int i = 0; i < lo; ++i)
if (!killed[i])
almostAll.push_back(i + 1);
int prv = lo;
killed[prv] = true;
sol[0].push_back(prv + 1);
for (int iEl = 1; iEl < parCouleur; ++iEl) {
lo = prv + 1, up = tot - 1;
while (lo < up) {
int mid = (lo + up) / 2;
vector<int> toQuery = almostAll;
for (int i = prv + 1; i <= mid; ++i)
if (!killed[i])
toQuery.push_back(i + 1);
if (Query(toQuery) >= 1)
up = mid;
else
lo = mid + 1;
}
killed[lo] = true;
sol[iEl].push_back(lo + 1);
prv = lo;
}
bef.push_back(prv + 1);
}
for (auto &s : sol)
Answer(s);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |