Submission #958287

#TimeUsernameProblemLanguageResultExecution timeMemory
958287lovrotSuper Dango Maker (JOI22_dango3)C++17
100 / 100
262 ms1104 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...