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;
namespace {
int query(set<int>& st) {
vector<int> a;
for (int x : st) a.push_back(x);
return Query(a);
}
} // namespace
void Solve(int N, int M) {
vector<vector<int>> byGroup;
vector<set<int>> notInGroups;
byGroup.resize(M);
notInGroups.resize(M);
for (int i=0; i<M; i++)
for (int j=1; j<=N*M; j++)
notInGroups[i].insert(j);
for (int i=1; i<=N*M; i++) {
int lb=0, ub=M-1;
while (lb != ub) {
int mid=(lb+ub+1)/2;
notInGroups[mid].erase(i);
int res = query(notInGroups[mid]);
notInGroups[mid].insert(i);
if (res >= M - mid) ub = mid-1;
else lb = mid;
}
byGroup[lb].push_back(i);
for (int j=lb+1; j<M; j++)
notInGroups[j].erase(i);
}
for (int i=0; i<M; i++) {
Answer(byGroup[i]);
}
}
# | 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... |