3810: [COCI2015]STANOVI__DP

Source: Internet
Author: User
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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.