# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
704906 | piOOE | 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 "dango3.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(228);
void Solve(int n, int m) {
const int N = n * m;
vector<int> ord(N);
iota(ord.begin(), ord.end(), 1);
shuffle(ord.begin(), ord.end(), rnd);
set<int> st;
while (!ord.empty()) {
for (int x: ord) {
st.insert(x);
if (Query(vector(st.begin(), st.end())) == 1) {
vector<int> stick{x};
vector<int> consider(st.begin(), st.end());
consider.erase(find(consider.begin(), consider.end(), x));
set<int> save;
for (int y: consider) {
st.erase(y);
if (stick.size() < n && Query(vector(st.begin(), st.end())) == 0) {
stick.push_back(y);
st.insert(y);
} else {
save.insert(y);
}
}
Answer(stick);
vector<int> nxt;
for (int z : ord) {
if (!st.count(z)) {
nxt.push_back(z);
}
}
swap(ord, nxt);
shuffle(ord.begin(), ord.end());
}
}
}
}