Pitcher Rotation

题意:

n个人m个对手给出每个人能战胜每个敌人的概率,现在有g个比赛,每个人赛完后要休息4天(可重复用),求能获得胜利的最大期望个数。

分析:

因为只有每个人5天就能用一次,所以对于每个人来说,只有得分前5的会被使用上,所以后4维状态只需要5^4,进行状态转移

dp[i][j][k][l][p]表示第i场比赛,前一天为j,两天为k,三天为l,四天为p,的最大得分,只和i-1状态有关用滚动数组。

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <complex>
#include <cassert>
#include <utility>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
#define lson l,m,rt<<1
#define pi acos(-1.0)
#define rson m+1,r,rt<<11
#define All 1,N,1
#define read freopen("in.txt", "r", stdin)
const ll  INFll = 0x3f3f3f3f3f3f3f3fLL;
const int INF= 0x7ffffff;
const int mod =  1000000007;
struct node{
    int id,v;
}win[110][110];
int dp[2][6][6][6][6],n,m,g,d[255];
bool cmp(node x,node y){
    return x.v>y.v;
}
int cal(int i,int j){
    if(i==0||j==0)return 0;
    return win[i][j].id;
}
int t;
 int main() {
        scanf("%d", &t);
        while (t--) {
           int ans = 0;
            scanf("%d%d%d", &n, &m, &g);
            for (int i = 1; i <= m; i++) {
                for (int j = 1; j <= n; j++) {
                    scanf("%d", &win[i][j].v);
                    win[i][j].id = j;
                }
                sort(win[i] + 1, win[i] + 1 + n, cmp);
            }
            g += 10;
            int i,j,k,y,l,x;
            for (i = 1; i <= g; i++)
                scanf("%d", &d[i]);
            memset(dp[0], 0, sizeof(dp[0]));
            int now=0;
            for (i = 1; i <= g; i++) {
                now^=1;
                memset(dp[now], 0, sizeof(dp[now]));
                if (d[i]) {
                    for (y = 1; y <= 5; y++) {
                        for (j = 0; j <= 5; j++) {
                            if (i > 1 && cal(d[i], y) == cal(d[i - 1], j)) continue;

                            for (k = 0; k <= 5; k++) {
                                if (i > 2 && cal(d[i], y) == cal(d[i - 2], k)) continue;

                                for (l = 0; l <= 5; l++) {
                                    if (i > 3 && cal(d[i], y) == cal(d[i - 3], l)) continue;
                                    for (x = 0; x <= 5; x++) {
                                        if (i > 4 && cal(d[i], y) == cal(d[i - 4], x)) continue;
                                        dp[now][y][j][k][l] = max(dp[now][y][j][k][l], dp[now^1][j][k][l][x] + win[d[i]][y].v);
                                        ans = max(ans, dp[now][y][j][k][l]);
                                    }
                                }
                            }
                        }
                    }
                }
                else {
                    for (j = 0; j <= 5; j++) {
                        for (k = 0; k <= 5; k++) {
                            for (l = 0; l <= 5; l++) {
                                for (x = 0; x <= 5; x++) {
                                    dp[now][0][j][k][l] = max(dp[now][0][j][k][l], dp[now^1][j][k][l][x]);
                                    ans = max(ans, dp[now][0][j][k][l]);
                                }
                            }
                        }
                    }
                }
            }
            printf("%.2lf\n", ans * 1.0 / 100);
        }
        return 0;
}
时间: 2024-10-22 04:39:05

Pitcher Rotation的相关文章

uva 1379 - Pitcher Rotation(dp)

题目链接:uva 1379 - Pitcher Rotation 题目大意:给出n,表示由n个人组成的战队,接着是m,表示有m个敌人,g表示要比赛的天数,给出g后,比赛的天数起始是g+10,然后是一个m*n的矩阵,g[i][j]表示第j个敌人被i打败后,战队所得到的分数.然后g+10个数,表示每天需要挑战的敌人是谁,0代表说休息:每个人出战的次数没有限制,但是比过一场后要休息4天,问说战队的最高得分. 解题思路:注意题目中的一点,说每个人比完一场赛后要休息4天,那么也就是说对于每个敌人来说,被派

UVA 1379 - Pitcher Rotation(DP + 贪心)

题目链接:1379 - Pitcher Rotation 题意:n个人,m个敌人,去比赛,有得分,n个人可以重复比,但是每次比完要休息4天,问最大得分 思路:dp[i][j][k][l][x] 表示第场比赛,前一天为j,两天为k,三天为l,四天为x,的最大得分,然后由于只有每个人5天就能用一次,所以对于每个人来说,只有得分前5的会被使用上,所以后4维状态只需要5^4,进行状态转移,不用比赛的情况分开考虑,还有这题内存有限,要用滚动数组优化不然会RE 代码: #include <stdio.h>

dp题目列表

10271 - Chopsticks 10739 - String to Palindrome 10453 - Make Palindrome 10401 - Injured Queen Problem 825 - Walking on the Safe Side 10617 - Again Palindrome 10201 - Adventures in Moving - Part IV 11258 - String Partition 10564 - Paths through the Ho

(IDA*)POJ 2286 The Rotation Game

The rotation game uses a # shaped board, which can hold 24 pieces of square blocks (see Fig.1). The blocks are marked with symbols 1, 2 and 3, with exactly 8 pieces of each kind. Initially, the blocks are placed on the board randomly. Your task is to

outdated: 4.Rotation

修改部分位于双行星号内. 1 #include <windows.h> 2 #include <gl/glew.h> 3 #include <gl/glut.h> 4 #include <GL/GLAUX.H> 5 6 /* 7 * Every OpenGL program is linked to a Rendering Context. 8 * A Rendering Context is what links OpenGL calls to the D

HDU 4708 Rotation Lock Puzzle (贪心+模拟)

Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1668    Accepted Submission(s): 530 Problem Description Alice was felling into a cave. She found a strange door with a number

hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup

http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Alice was felling into a cave. She found a strange door with a number square m

【HackerRank】Game Of Rotation

题目连接:Game Of Rotation Mark is an undergraduate student and he is interested in rotation. A conveyor belt competition is going on in the town which Mark wants to win. In the competition, there's A conveyor belt which can be represented as a strip of 1

Centos 7周期性任务、日志rotation、过滤和core压缩的实现

Centos 7周期性任务日志rotation.过滤和core压缩的实现 1.centos7中cron脚本及其调用脚本的实现示例 [[email protected] cron.d]# pwd /etc/cron.d [[email protected] cron.d]# cat syslog # Run mysys activity accounting tool every 10 minutes */5 * * * * root /usr/sbin/mysyslog.sh 2>&1 &g