# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
553700 | amunduzbaev | Super Dango Maker (JOI22_dango3) | C++17 | 35 ms | 548 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"
#ifndef EVAL
#include "grader.cpp"
#endif
#include "bits/stdc++.h"
using namespace std;
void Solve(int n, int m) {
vector<int> a(n * m);
iota(a.begin(), a.end(), 0);
for(int i=m;i>0;i--){
int j=n*i-1;
vector<int> tmp;
auto ask = [&](int j){
vector<int> tt;
for(int i=0;i<=j;i++) tt.push_back(a[i] + 1);
for(auto x : tmp) tt.push_back(a[x] + 1);
return Query(tt);
};
while(j >= 0){
if(ask(j)){
if(!j) {
tmp.push_back(j);
break;
}
j = max(j - i, 0);
} else {
int l = j, r = j + i;
while(l < r){
int m = (l + r) >> 1;
if(ask(m)) r = m;
else l = m + 1;
}
tmp.push_back(l);
j = l - 1;
}
}
auto give = [&](vector<int>& tt){
reverse(tt.begin(), tt.end());
/* for(auto x : tt) cout<<x<<" ";
cout<<"\n";
for(auto x : a) cout<<x<<" ";
cout<<"\n"; */
vector<int> tmp, qq;
for(int j=0, l=0;j<n*i;j++){
if(l<n && tt[l] == j) {
qq.push_back(a[j] + 1);
l++;
continue;
}
tmp.push_back(a[j]);
}
swap(tmp, a);
Answer(qq);
assert(qq.size() == n);
};
assert(tmp.size() == n);
give(tmp);
}
}
/*
3 2
3 3 1 2 1 2
*/
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... |