# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
554612 | Arvin | Super Dango Maker (JOI22_dango3) | C++17 | 409 ms | 604 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
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);
}
int lst = len-1;
for(int x=len-1;x>=0;x--){
int res = Query(v);
if(res >= 1){
lst = x;
}
v.pop_back();
}
bool valid[len];
fill(valid, valid+len, false);
for(int x=0;x<=lst;x++) valid[x] = true;
for(int x=0;x<=lst;x++){
valid[x] ^= 1;
vector<int> w;
for(int y=0;y<=lst;y++){
if(valid[y]){
w.push_back(y+1);
}
}
int res = Query(w);
if(res >= 1){
continue;
}
valid[x] ^= 1;
}
int c[len];
fill(c, c+len, -1);
v.clear();
for(int x=0;x<=lst;x++){
if(valid[x]){
v.push_back(x+1);
}
}
for(int x=0;x<v.size();x++){
c[v[x]-1] = x;
}
for(int x=0;x<v.size()-1;x++){
vector<int> w;
for(int y=0;y<x;y++){
w.push_back(v[y]);
}
for(int y=x+1;y<v.size();y++){
w.push_back(v[y]);
}
int cnt = 1;
for(int y=0;y<len&&cnt<m;y++){
if(c[y] == -1){
w.push_back(y+1);
if(Query(w) >= 1){
cnt++;
c[y] = c[v[x]-1];
}
w.pop_back();
}
}
}
for(int x=0;x<len;x++){
if(c[x] == -1){
c[x] = c[v.back()-1];
}
}
vector<int> ans[n];
for(int x=0;x<len;x++){
ans[c[x]].push_back(x);
}
for(int x=0;x<m;x++){
vector<int> w;
for(int y=0;y<n;y++){
w.push_back(ans[y][x]+1);
}
Answer(w);
}
// 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... |