#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
428 KB |
Output is correct |
2 |
Correct |
15 ms |
340 KB |
Output is correct |
3 |
Correct |
29 ms |
384 KB |
Output is correct |
4 |
Correct |
29 ms |
340 KB |
Output is correct |
5 |
Correct |
10 ms |
340 KB |
Output is correct |
6 |
Correct |
13 ms |
404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
202 ms |
584 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
485 ms |
648 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |