# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
696108 | hpesoj | Super Dango Maker (JOI22_dango3) | C++17 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
//#include "dango3.h"
#define pi pair <int, int>
#define ppi pair <pi, int>
#define fi first
#define se second
#define pb push_back
using namespace std;
void Solve(int n, int m) {
vector <int> v;
for(int i = 1; i <= n * m; i++) v.pb(i);
vector <int> sticks[m+1];
sticks[1].pb(1);
for(int i = 2; i <= n * m; i++){
int lo = 1, hi = m;
while(lo < hi){
int mid = (lo + hi) >> 1;
for(int j = 0; j < sticks[mid].size(); j++) v.erase(find(v.begin(), v.end(), sticks[mid][j]));
v.erase(find(v.begin(), v.end(), i));
if(Query(v) == m-2) hi = mid;
else lo = mid + 1;
v.pb(i);
for(int j = 0; j < sticks[mid].size(); j++) v.pb(sticks[mid][j]);
}
sticks[lo].pb(i);
}
for(int i = 1; i <= m; i++) Answer(sticks[i]);
}