This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Be name khoda //
#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pb push_back
#define fi first
#define se second
#define mp make_pair
namespace {
const int maxn = 405;
const int maxm = 27;
bool mark[maxn * maxm];
vector <int> av[maxm << 2];
int variable_example = 1, m, n;
void build(int l, int r, int v){
for(int i = l; i < r; i++)
av[v].pb(i);
if(r - l == 1)
return;
int mid = (l + r) >> 1;
build(l, mid, v * 2);
build(mid, r, v * 2 + 1);
}
void out(int l, int r, int v){
if(r - l == 1){
vector <int> ans;
ans.clear();
for(auto u : av[v])
ans.pb(u + 1);
Answer(ans);
return;
}
int mid = (l + r) >> 1;
out(l, mid, v * 2);
out(mid, r, v * 2 + 1);
}
inline int ask(int v, int id){
vector <int> tmp;
tmp.clear();
memset(mark, false, sizeof mark);
for(auto u : av[v])
mark[u] = true;
mark[id] = true;
for(int i = 0; i < n * m; i++) if(!mark[i])
tmp.pb(i + 1);
return Query(tmp);
}
void place(int l, int r, int id, int v){
av[v].pb(id);
if(r - l == 1)
return;
int mid = (l + r) >> 1;
if(m - ask(v * 2, id) <= mid - l)
place(l, mid, id, v * 2);
else
place(mid, r, id, v * 2 + 1);
}
}
void Solve(int N, int M){
m = M;
n = N;
build(0, m, 1);
for(int i = m; i < n * m; i++)
place(0, m, i, 1);
out(0, m, 1);
}
Compilation message (stderr)
dango3.cpp:26:9: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
26 | int variable_example = 1, m, n;
| ^~~~~~~~~~~~~~~~
# | 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... |