# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1077868 | 0npata | Super Dango Maker (JOI22_dango3) | C++17 | 262 ms | 1112 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;
#define vec vector
const int MXSZ = 400*25;
vec<int> ri_to;
vec<int> ri_from;
int query(vec<int> v) {
for(int i = 0; i<v.size(); i++) {
v[i] = ri_to[v[i]]+1;
//cerr << v[i] << ' ';
}
//cerr << '\n';
return Query(v);
}
void Solve(int N, int M) {
srand(69);
ri_to = vec<int>(N*M);
iota(ri_to.begin(), ri_to.end(), 0);
random_shuffle(ri_to.begin(), ri_to.end());
vec<vec<int>> cols_inds{};
vec<int> rem(N*M);
iota(rem.begin(), rem.end(), 0);
while(cols_inds.size() < N) {
//cerr << "NEW ONE" << '\n';
vec<int> v{};
for(auto cis : cols_inds) {
v.push_back(cis[0]);
}
int l = 0;
int r = rem.size();
while(l<r) {
int m = (l+r)/2;
vec<int> qv = v;
for(int i = 0; i<=m; i++) {
qv.push_back(rem[i]);
}
//cerr << '\n';
int res = query(qv);
if(res >= 1) {
r = m;
}
else {
l = m+1;
}
}
vec<int> col_inds{rem[l]};
for(int i = 0; i<l; i++) v.push_back(rem[i]);
// now v contains everything at least once except the col
// therefore the first one will always correspond to the same col
while(col_inds.size() < M) {
//cerr << "HERE" << '\n';
l++;
int last = l;
int r = rem.size();
while(l<r) {
int m = (l+r)/2;
auto qv = v;
for(int i = last; i<=m; i++) {
qv.push_back(rem[i]);
}
int res = query(qv);
if(res >= 1) {
r = m;
}
else {
l = m+1;
}
}
col_inds.push_back(rem[l]);
}
assert(col_inds.size() == M);
cols_inds.push_back(col_inds);
set<int> nrem(rem.begin(), rem.end());
for(int ind : col_inds) {
//cerr << ind << ' ';
nrem.erase(ind);
}
//cerr << '\n';
rem = vec<int>(nrem.begin(), nrem.end());
}
for(int i = 0; i<M; i++) {
vec<int> ans(N);
for(int j = 0; j<N; j++) {
ans[j] = ri_to[cols_inds[j][i]]+1;
}
Answer(ans);
}
}
Compilation message (stderr)
# | 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... |