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 Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
namespace {
mt19937_64 rd(time(0));
void Do(vector<int> vec, int n, int m)
{
if (m == 0)
return;
int cnt = min(m, 4);
vector<int> q;
for (;;) {
shuffle(vec.begin(), vec.end(), rd);
q = vector<int>(vec.begin(), vec.begin() + n*cnt);
if (Query(q))
break;
}
vector<int> idx;
LoopR (i,0,q.size()) {
int tmp = q[i];
swap(q[i], q.back());
q.pop_back();
if (Query(q) == 0) {
q.push_back(tmp);
idx.push_back(i);
}
}
for (int &i : idx) {
int tmp = vec[i];
swap(vec[i], vec.back());
vec.pop_back();
i = tmp;
}
Answer(idx);
Do(vec, n, m-1);
}
} // namespace
void Solve(int N, int M) {
vector<int> vec(N*M);
iota(vec.begin(), vec.end(), 1);
Do(vec, N, M);
}
# | 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... |