# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
554620 | Arvin | Super Dango Maker (JOI22_dango3) | C++17 | 893 ms | 274184 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;
//namespace {
// int variable_example = 1;
//} // namespace
map<vector<int>, int> mp;
void Solve(int n, int m) {
int len = n*m;
vector<int> v;
for(int x=0;x<len;x++){
v.push_back(x+1);
}
auto ask = [&](vector<int> &v) -> int {
if(mp.count(v)) return mp[v];
return mp[v] = Query(v);
};
int cnt = m;
while(cnt > 0){
vector<int> w = v;
int lst = 0;
int left = 0, right = w.size()-1;
while(left <= right){
int mid = (left+right) >> 1;
vector<int> z;
for(int x=0;x<=mid;x++){
z.push_back(w[x]);
}
if(ask(z) > 0){
lst = mid;
right = mid-1;
} else {
left = mid+1;
}
}
vector<int> ans;
int pos = 0;
while(pos < lst){
int bound = 0;
int left = pos, right = lst;
while(left <= right){
int mid = (left+right) >> 1;
vector<int> z = ans;
for(int x=mid;x<=lst;x++){
z.push_back(w[x]);
}
if(ask(z) > 0){
bound = mid;
left = mid+1;
} else {
right = mid-1;
}
}
ans.push_back(w[bound]);
pos = bound+1;
}
ans.push_back(w[lst]);
v.clear();
pos = 0;
for(int x=0;x<w.size();x++){
while(pos < ans.size() && ans[pos] < w[x]){
pos++;
}
if(pos < ans.size() && ans[pos] == w[x]) continue;
v.push_back(w[x]);
}
Answer(ans);
cnt--;
}
// vector<int> x(3);
// x[0] = 1;
// x[1] = 2;
// x[2] = 3;
// variable_example = Query(x);
// for (int i = 0; i < M; i++) {
// std::vector<int> a(N);
// for (int j = 0; j < N; j++) {
// a[j] = N * i + j + 1;
// }
// Answer(a);
// }
}
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... |