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