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>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
// #define int LL
using namespace std;
using LL = long long;
using pii = pair<int, int>;
namespace {
vector<int> cand;
vector<int> res;
int amyamya() {
vector<int> v(all(res));
int hi = sz(cand), lo = 0;
while(hi - lo > 1) {
int mi = (hi + lo) / 2;
For(i, 0, mi - 1) v.eb(cand[i]);
if(Query(v) == 0) lo = mi;
else hi = mi;
v.erase(v.begin() + sz(res), v.end());
}
int k = cand[lo];
swap(cand[lo], cand.back());
cand.pop_back();
return k;
}
} // namespace
void Solve(int32_t N, int32_t M) {
// assert(max(N, M) <= 4);
For(i, 1, N * M) {
cand.eb(i);
}
For(i, 1, M) {
res.clear();
For(j, 1, N) res.eb(amyamya());
// For(j, 0, N - 1) cout << res[j] << " \n"[j == N - 1];
Answer(res);
}
}
/*
g++ -std=c++14 -O2 -o grader grader.cpp dango3.cpp & grader.exe < input.txt > output.txt 2> error.txt
*/
# | 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... |