Hdu--4800--dp

Source: Internet
Author: User

There's a total of 2 different states of transition.

When we move the state from X to Y, we can choose to change players or not to change players, but one thing to be aware of is that if you want to change players, it's just the latest game.

And there's always an increase in the number of matches. We always from (x-1)---->x It is also logical that we must first play in the X-1 field in order to play in the X game.

Dp[x,y] indicates that at the time of the current X game, I was numbering in Y for < attention because this is where the game must be done in order, so that means that the first n field is all the games are finished >

Dp[x][y] = max (Dp[x][y], dp[x-1][y]*p[y][team[x]);//No replacement

Dp[x][y] = max (dp[x][team[x], dp[x-1][y]*p[y][team[x]]);//replacement

1#include <iostream>2#include <algorithm>3 using namespacestd;4 5 intN, M;6 Const intSize = -;7 Doubledp[10010][size];8 DoubleP[size][size];9 intteam[10010];Ten  One voidSolve () A { -      for(inti =0; I<=m; i++ ) -dp[0][i] =1.0; the      for(inti =1; I<=n; i++ ) -     { -          for(intj =0; J<m; J + + ) -         { +DP[I][J] = max (Dp[i][j], dp[i-1][j]*p[j][Team[i]]); -dp[i][Team[i]] = max (dp[i][team[i]), dp[i-1][j]*p[j][Team[i]]); +         } A     } at } -  - intMain () - { -     Doubleans; -      while(~SCANF ("%d",&m)) in     { -m = m * (M-1) * (M-2) /6; to          for(inti =0; I<m; i++ ) +         { -              for(intj =0; J<m; J + + ) the             { *scanf"%LF",&p[i][j]); $             }Panax Notoginseng         } -scanf"%d",&n); the          for(inti =1; I<=n; i++ ) +         { Ascanf"%d",&team[i]); the         } +Memset (DP,0,sizeof(DP)); - solve (); $Ans =0; $          for(inti =0; I<m; i++ ) -         { -Ans =Max (ans, dp[n][i]); the         } -printf"%.6lf\n", ans);Wuyi     } the     return 0; -}
View Code

Today

It sucks.

Ffffffffk

  

Hdu--4800--dp

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.