HDU 3720 Arranging Your Team(DFS)
队内赛里,匆匆忙忙写的。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int v[];
int flag[];
int o[][];
int p[];
char name[];
char fa[];
int que[][];
int s[];
int sf[];
int key[];
int maxz;
int judge(char *str)
{
if(strcmp("goalkeeper",str) == )
return ;
else if(strcmp("defender",str) == )
return ;
else if(strcmp("midfielder",str) == )
return ;
else if(strcmp("striker",str) == )
return ;
return ;
}
void dfs(int y,int x,int step,int sd)
{
int i,j,k,st;
if(step > )
{
st = ;
for(j = ;j < ;j ++)
st += v[p[j]];
for(j = ; j < ; j ++)
{
for(k = j+; k < ; k ++)
st += o[p[j]][p[k]];
}
maxz = max(st,maxz);
return ;
}
for(i = y;i < s[step];i ++)
{
if(!sf[que[step][i]])
{
sf[que[step][i]] = ;
p[sd] = que[step][i];
if(x+ > key[step])
dfs(,,step+,sd+);
else
dfs(i+,x+,step,sd+);
sf[que[step][i]] = ;
}
}
return ;
}
int main()
{
int i,m,sc;
key[] = ;
key[] = ;
key[] = ;
key[] = ;
while(scanf("%s%d%s",name,&v[],fa)!=EOF)
{
memset(o,,sizeof(o));
memset(s,,sizeof(s));
memset(sf,,sizeof(sf));
memset(que,,sizeof(que));
map<string,int> mp;
mp[name] = ;
flag[] = judge(fa);
que[flag[]][s[flag[]]] = ;
s[flag[]] ++;
for(i = ; i < ; i ++)
{
scanf("%s%d%s",name,&v[i],fa);
mp[name] = i;
flag[i] = judge(fa);
que[flag[i]][s[flag[i]]] = i;
s[flag[i]] ++;
}
scanf("%d",&m);
for(i = ; i < m; i ++)
{
scanf("%s%s%d",name,fa,&sc);
int a,b;
a = mp[name];
b = mp[fa];
o[a][b] += sc;
o[b][a] += sc;
}
if(s[] < ||s[] < ||s[] < ||s[] < )
{
printf("impossible\n");
continue;
}
maxz = -;
dfs(,,,);
printf("%d\n",maxz);
}
return ;
}
HDU 3720 Arranging Your Team(DFS)的更多相关文章
- HDU 3720 Arranging Your Team
先分组,然后暴力:注意 初始化时不要为0 会有负数:我直接二进制枚举: dfs是正解:呵呵 #include <iostream> #include <cstdio> #in ...
- hdu 3720 Arranging Your Team 枚举
不可能解可以直接判断. 搭配产生的附加分可以用一个二维数组保存. 枚举1442,4种类型的人,因为总人数只有23个,所以可以搜索暴力枚举,然后保存最优解. 注意trick,答案可能为负数,所以初始化a ...
- hdu3720 Arranging Your Team
Arranging Your Team Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- HDU 1241 Oil Deposits --- 入门DFS
HDU 1241 题目大意:给定一块油田,求其连通块的数目.上下左右斜对角相邻的@属于同一个连通块. 解题思路:对每一个@进行dfs遍历并标记访问状态,一次dfs可以访问一个连通块,最后统计数量. / ...
- hdu 1241 Oil Deposits(DFS求连通块)
HDU 1241 Oil Deposits L -DFS Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & ...
- HDOJ(HDU).1258 Sum It Up (DFS)
HDOJ(HDU).1258 Sum It Up (DFS) [从零开始DFS(6)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双 ...
- HDOJ(HDU).1016 Prime Ring Problem (DFS)
HDOJ(HDU).1016 Prime Ring Problem (DFS) [从零开始DFS(3)] 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架 ...
- Arranging Your Team HDU - 3720 【DFS】
思路 题意:此题大意是指首先给你23个队员的信息,包括他们的名字,能力值,在赛场上的职位.然后给出几个若能满足某两个队员同时在球场上就额外加上一定的值.最后让你从23个队员中选出11个人,使得最终的v ...
- 2017ACM暑期多校联合训练 - Team 9 1005 HDU 6165 FFF at Valentine (dfs)
题目链接 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any other ...
随机推荐
- win10总是自动重启的解决办法
win10总是自动重启的解决办法_百度经验http://jingyan.baidu.com/article/7908e85c983523af481ad214.html
- PHP连接打印机
<?php header("Content-type: text/html; charset=utf-8"); class Netprint{ public $host = ...
- Jquery获取iframe子/父窗口中的标签
获取子窗口中的标签: $("#id",document.frames('iframename').document); 获取父窗口中的标签: $('#id', parent.doc ...
- hdu 2509 博弈 *
多堆的情况要处理好孤单堆 #include<cstdio> #include<iostream> #include<algorithm> #include<c ...
- 提供给Android和iOS开发人员的UWP移植向导
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:前几天微软发布了一个针对Android和iOS开发人员理解Windows Apps概念 ...
- Spring之ResourceLoader加载资源
Resource与ResourceLoader对比 1.Resource接口定义了应用访问底层资源的能力. 通过FileSystemResource以文件系统绝对路径的方式进行访问: 通过ClassP ...
- Computer Graphics Research Software
Computer Graphics Research Software Helping you avoid re-inventing the wheel since 2009! Last update ...
- ViewPager onPageChangeListener总结(转)
android ViewPager滑动事件讲解 今天在做项目的时候,由于要处理viewPager页面滑动的事件,所以对其进行了一个小小的研究: 首先ViewPager在处理滑动事件的时候要用到OnPa ...
- windows下R语言在终端的运行
在windows下可以有多种方式来运行R,R导论的这些章节给出一些详细的指导. 通常在环境变量离包含R的安装目录类似于R\R-3.1.2\bin\x64的情况下,就可以在CMD下运行R程序了 注意我这 ...
- Windows服务定时执行任务
1.创建多线程类 /// <summary> /// 多线程 /// </summary> public abstract class MuliThread<T> ...