#include <bits/stdc++.h>
#include "dango3.h"
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 400 * 25 + 100, M = 4096 + 10, len = 1e5, inf = 1e18;
const ll mod = 1e9 + 7;
namespace {
int var = 1;
} // namespace
bool was[N];
vector <int> gr[N], all;
int get(int x, int times){
vector <int> vec;
for(int i = times - 1; i >= 1; i--){
vec.pb(gr[i][0]);
}
for(int i = 1; i <= x; i++){
vec.pb(all[i]);
}
return Query(vec);
}
void Solve(int n, int m) {
for(int times = 1; times <= n; times++){
all.clear();
all.pb(-1);
for(int i = 1; i <= n * m; i++){
if(was[i]) continue;
all.pb(i);
}
int l = 0, r = n * m - (times - 1) * m;
for(int i = 0; i < m; i++){
while(r - l > 1){
int mid = (l + r) / 2;
if(get(mid, times) >= 1) r = mid;
else l = mid;
}
gr[times].pb(all[r]);
was[all[r]] = true;
l = r;
r = n * m;
}
}
for(int times = 1; times <= m; times++){
vector <int> vec;
for(int i = 1; i <= n; i++){
vec.pb(gr[i].back());
gr[i].pop_back();
}
Answer(vec);
}
}
# | 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... |