这题上来我是没有思路的。因为目标值关涉到的因素太多而直接枚举的复杂度又太高。

目标值由两部分合成,一部分是队员的CA和与PA和,另一部分是队员之间的relationship。

前者是简单的代数累加,而后者显然才是本题需要解决的问题。

由于relatioship由具体的出场方案所决定,因此不知道哪些队员上场就不可能知道它的值是多少,并且估算它有用的上下界也是困难的。

因此只能想到枚举,首先枚举哪些队员上场(这一步的复杂度就非常高,如果按题目给的数据范围对于强数据是根本不可能通过的)。

于是第二部分的值就确定了,现在只需要解决第一部分的求值。

这一部分不需要暴力枚举(如果仍然枚举仅在此处最坏情况下复杂度也会上万),因为既然是代数和的累加必然可以找到不同状态之间的联系。

对于某个特定的队员只会被任命在4个位置中的一个,现在方案只会是内部队员出场位置的调整。那么我们可以想到dp,通过枚举-更新的方法寻求最佳方案。

 #include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <ctime>
#pragma comment(linker, "/STACK:102400000,102400000")
#define lson (u << 1)
#define rson (u << 1 | 1)
#define rep(i, a, b) for(i = a; i < b; i++)
#define repi(i, a, b, c) for(i = a; i < b; i += c)
#define cls(i, j) memset(i, j, sizeof i);
using namespace std;
typedef long long ll;
const double eps = 1e-;
const double pi = acos(-1.0);
const int maxn = + ;
const int maxm = ;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3fffffffffffffff;
const ll mid = 1e9 + ; struct P{
int id, o[];
int c[], p[], cmax;
bool operator < (const P &rhs) const{
return cmax > rhs.cmax;
}
}a[maxn]; int n, m;
int idx[maxn];
int g[maxn][maxn]; int f(char ch){
switch(ch){
case 'G' : return ;
case 'D' : return ;
case 'M' : return ;
case 'S' : return ;
}
} int select[];
int l[]; struct Point{
int x, y;
Point(int x = , int y = ) : x(x), y(y) {}
bool operator < (const Point &rhs){
return x < rhs.x || x == rhs.x && y < rhs.y;
}
Point operator + (const Point &rhs){
return Point(x + rhs.x, y + rhs.y);
}
bool operator == (const Point &rhs){
return x == rhs.x && y == rhs.y;
}
}dp[][][][];//i, 0, 1, 2 Point ANS, INF = Point{-inf, -inf}; Point max(Point lhs, Point rhs) { return lhs < rhs ? rhs : lhs; } void update(int u, int kind, int n0, int n1, int n2){
Point dest = dp[u][n0][n1][n2] + Point{a[select[u]].c[kind], a[select[u]].p[kind]};
Point *src = &dp[u + ][n0 + ( == kind)][n1 + ( == kind)][n2 + ( == kind)];
(*src) = max((*src), dest);
} void cal(){
int cnt[];
cls(cnt, );
int i, j, k, u, v;
rep(i, , ) rep(j, , ) if(a[select[i]].o[j]) ++cnt[j];
rep(i, , ) if(cnt[i] < l[i]) return;
int ca = ;
rep(i, , ) rep(j, i, ){
int x = a[select[i]].id, y = a[select[j]].id;
ca += g[x][y];
if(i != j) ca += g[y][x];
}
int high = ca;
rep(i, , ) high += a[select[i]].cmax;
if(high < ANS.x) return;//curcial pruning
rep(i, , ) rep(j, , cnt[] + )
rep(k, , cnt[] + ) rep(u, , cnt[] + ) dp[i][j][k][u] = INF;
dp[][][][] = Point{, };
rep(i, , ) rep(j, , l[] + ) rep(k, , l[] + ) rep(u, , l[] + ){
if(dp[i][j][k][u] == INF) continue;
rep(v, , ) if(a[select[i]].o[v]) update(i, v, j, k, u);
}
ANS = max(ANS, Point(ca, ) + dp[][l[]][l[]][l[]]);
} void fswap(int x, int y){
int i;
rep(i, , n) swap(a[i].c[x], a[i].c[y]), swap(a[i].p[x], a[i].p[y]), swap(a[i].o[x], a[i].o[y]);
swap(l[x], l[y]);
} void dfs(int pos, int num){
//num::how many palyers has been chosen
if(num == ){
cal();
return;
}
if(pos == n || n - pos + num < ) return;
select[num] = pos;
dfs(pos + , num + );
dfs(pos + , num);
} void solve(){
ANS = INF;
dfs(, );
if(ANS == INF) puts("Poor Manager!");
else printf("%d %d\n", ANS.x, ANS.y);
} int main(){
//freopen("in.txt", "r", stdin);
int T;
scanf("%d", &T);
char buf[];
while(T--){
scanf("%d", &n);
int i, j, tem;
rep(i, , n) rep(j, , ) a[i].o[j] = ;
rep(i, , n){
a[i].cmax = -inf;
scanf("%d%d", &a[i].id, &tem);
rep(j, , tem){
scanf("%s", buf);
int tem1 = f(buf[]);
a[i].o[tem1] = ;
scanf("%d%d", &a[i].c[tem1], &a[i].p[tem1]);
a[i].cmax = max(a[i].cmax, a[i].c[tem1]);
}
}
cls(g, );
sort(a, a + n);
scanf("%d", &m);
rep(i, , m){
int u, v, w;
scanf("%d%d%s%d", &u, &v, buf, &w);
g[u][v] = (buf[] == 'D' ? - : ) * w;
}
scanf("%d-%d-%d", &l[], &l[], &l[]);
l[] = - l[] - l[] - l[];
int maxp = , maxv = l[];
rep(i, , ) if(l[i] > maxv) maxv = l[i], maxp = i;
if(maxp != ) fswap(, maxp);
solve();
}
return ;
}

hdu4924 Football Manager的更多相关文章

  1. WOJ 124. Football Coach 网络流

    Problem 1124 - Football Coach Description It is not an easy job to be a coach of a football team. Th ...

  2. CodeForces-1244C-The Football Season-思维

    The football season has just ended in Berland. According to the rules of Berland football, each matc ...

  3. Windows下Redis缓存服务器的使用 .NET StackExchange.Redis Redis Desktop Manager

    Redis缓存服务器是一款key/value数据库,读110000次/s,写81000次/s,因为是内存操作所以速度飞快,常见用法是存用户token.短信验证码等 官网显示Redis本身并没有Wind ...

  4. 如何重新注册VMware Update Manager(VUM)至vCenter Server中

    在VMware的vSphere化境中,VUM的角色相当于Windows 环境中的WSUS(Windows 更新服务器),可以批量,自动化的完成所管辖ESXi主机的大版本迁移,小版本升级的任务,深受管理 ...

  5. 使用tomcat manager 管理和部署项目

    在部署tomcat项目的时候,除了把war文件直接拷贝到tomcat的webapp目录下,还有一种方法可以浏览器中管理和部署项目,那就是使用tomcat manager. 默认情况下,tomcat m ...

  6. Ubuntu管理开机启动服务项 -- 图形界面的Boot-up Manager

    有时学习时安装的服务太多,比如mysql.mongodb.redis.apache.nginx等等,它们都是默认开机启动的,如果不想让它们开机启动,用到时再自己手工启动怎么办呢? 使用sysv-rc- ...

  7. Android SDK Manager 更新代理配置

    转自:http://www.cnblogs.com/tao560532/p/4483067.html 出现问题: 消除SDK更新时,有可能会出现这样的错误:Download interrupted: ...

  8. 通读AFN①--从创建manager到数据解析完毕

    流程梳理 今天开始会写几篇关于AFN源码解读的一些Blog,首先要梳理一下AFN的整体结构(主要是讨论2.x版本的Session访问模块): 我们先看看我们最常用的一段代码: AFHTTPSessio ...

  9. SQL Server恢复软件SysTools SQL Recovery/SysTools SQL Server Recovery Manager

    SQL Server恢复软件SysTools SQL Recovery/SysTools SQL Server Recovery Manager http://www.systoolsgroup.co ...

随机推荐

  1. docker note

    docker --bip="10.1.42.1/16" -d 挂载宿主机目录 Docker支持挂载宿主机目录,支持宿主机目录和容器之间文件目录进行映射,彼此共享: docker r ...

  2. iOS 顺传

    ios 顺传一层的话,直接用属性 改变里面的值 顺传穿两到三层的话 使用KVO // 设置item - (void)setItem:(UITabBarItem *)item { _item = ite ...

  3. hdu1247(字典树+枚举)

    Hat's Words(hdu1247) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...

  4. yii添加行的增删改查

    效果图: 控制器: <?phpnamespace backend\controllers;use Yii;use yii\web\Controller;use backend\models\Zh ...

  5. EXTJS 5 开发环境搭建

    WEBstrom eclipse下载: http://www.eclipse.org/downloads/ spket 下载: 安装方式: http://wangke0611.iteye.com/bl ...

  6. 关于windows操作系统的内核

    操作系统内核.从本质上来讲,它本身也是一个程序.比如windows的内核 ntoskrnl.exe 就是一个我们平常看到的 PE 文件,它的位置位于 \WINDOWS\system32\ntoskrn ...

  7. 《zw版·delphi与halcon系列原创教程》hello,zw

    <zw版·delphi与halcon系列原创教程>hello,zw 按惯例,第一个程序是‘hello’ 毕竟,Halcon是专业的图像库,所以我们就不用纯文本版的,来一个专业版.Halco ...

  8. Mysql 的存储引擎,myisam和innodb的区别

    MyISAM 是非事务的存储引擎,innodb是支持事务的存储引擎. innodb的引擎比较适合于插入和更新操作比较多的应用,而MyISAM 则适合用于频繁查询的应用 . MyISAM --表锁,in ...

  9. 《OpenGL着色语言》理解点记录二

    别人提到“OpenGL的处理管线”时,意味着什么? 准确的讲,应该是“OpenGL图形处理管线”,“管线”带有特定的顺序,在OpenGL中就是Graphics Processing Pipeline. ...

  10. 1行代码,删除svn文件夹

    引用:http://www.cnblogs.com/Alexander-Lee/archive/2010/02/23/1671905.html linux操作系统: find -name .svn | ...