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 <vector>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 30;
const int OO = 2e9;
int DP[MAXN], I[MAXN];
void dnc(vector<int> V, int n) {
if(n == 1) {
Answer(V);
return;
}
vector<int> _V;
for(int i = (int) V.size() - 1; i >= 0; --i) {
int x = V[i];
V.erase(V.begin() + i);
if(Query(V) >= I[n]) _V.push_back(x);
else V.push_back(x);
}
dnc(V, I[n]);
dnc(_V, n - I[n]);
}
void Solve(int N, int M) {
DP[1] = 0;
for(int i = 2; i <= M; ++i) {
DP[i] = OO;
for(int j = 1; j < i; ++j)
if(DP[i] > DP[j] + DP[i - j] + i) {
DP[i] = DP[j] + DP[i - j] + i;
I[i] = j;
}
}
vector<int> V;
for(int i = 1; i <= N * M; ++i) V.push_back(i);
dnc(V, M);
}
# | 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... |