3810: [Coci2015]stanoviTime limit:15 Sec Memory limit:64 MB
submit:650 solved:302
[Submit] [Status] [Discuss]
Description
Input Enter one line, three integers, N, m, K
output outputs a number that represents the minimum degree of dissatisfaction. Sample Input 3 3 2 Sample Output 1
"Hint"
See the split scheme of the left graph in the description, with a minimum unsatisfied degree of 4 * (2-2) ^ 2 + (1-2) ^ 2 = 1.
"Data Range"
N, M <= 300
K <= 10000
HINT
Source
Acknowledgements Dzy
[Submit] [Status] [Discuss]
define the state F[n][m][u][d][l][r] for the side length is the n*m rectangle, whether the edges are affixed to the boundary, the optimal cutting scheme obviously, each cut at least one knife to the end, so violent enumeration, the memory of the search on the line but this will tle, the symmetry of the situation appropriate pruning, reduce the total number of States can
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <queue > #include <algorithm> #include <cmath> #include <stack> #define MIN (a,b) ((a) < (b)?
(a): (b)) using namespace Std;
const int N = 303;
typedef long Long LL;
int n,m,k;
BOOL Vis[n][n][2][2][2][2];
LL f[n][n][2][2][2][2];
inline LL Dfs (int n,int m,int l,int r,int u,int D) {if (N > M) Swap (n,m), swap (u,l), swap (D,R); if (U &&!d) swap (U,D);
if (l &&!r) swap (L,R);
if (Vis[n][m][l][r][u][d]) return f[n][m][l][r][u][d];
F[N][M][L][R][U][D] = 1LL * (n * m-k) * (n * m-k); if (U | | | d | |
(l && R)) for (int i = 1; i < M i++) f[n][m][l][r][u][d] = min (F[n][m][l][r][u][d],dfs (n,i,l,0,u,d) + DFS (n,m-i,0,
R,U,D)); if (l | | r | |
(U && d)) for (int i = 1; i < N; i++) f[n][m][l][r][u][d] = min (F[n][m][l][r][u][d],dfs (i,m,l,r,u,0) + DFS (n-i,m,l,
R,0,D)); VIS[N][M][L][R][U][D] = 1;
return f[n][m][l][r][u][d];
int main () {#ifdef DMC freopen ("DMC.txt", "R", stdin);
#endif cin >> n >> m >> K;
cout << Dfs (n,m,1,1,1,1) << Endl;
return 0; }