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 ...
随机推荐
- 【openGL】画直线
#include "stdafx.h" #include <GL/glut.h> #include <stdlib.h> #include <math ...
- Git学习笔记 git revert
我们难免会因为种种原因执行一些错误的commit / push,git提供了revert命令帮助程序员修复这样的错误. 举个例子,下图是git commit 的历史记录 git revert 命令会通 ...
- WCF 回调中操作线程
回调的类 [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant, UseSynchronizationContext = fals ...
- 在ASP.NET 5中使用SignalR
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:SignalR作为ASP.NET中进行Web实时双向通信的组件,在ASP.NET 5中 ...
- eclipse文本编码格式修改为UTF-8 (转)
如果要使插件开发应用能有更好的国际化支持,能够最大程度的支持中文输出,则最好使 Java文件使用UTF-8编码.然而,Eclipse工作空间(workspace)的缺省字符编码是操作系统缺省的编码,简 ...
- silverlight和wpf中暴露 给子类override
protected virtual void OnSelectionChanged(SelectionChangedEventArgs args) { } public TestTabControl( ...
- Vue#Class 与 Style 绑定
绑定HTMLCLASS 在我没看这之前,我觉得要写绑定class ,应该像绑定数据一样这么写 class ={{class-a}} 看官方教程时,不推荐这么写,推荐这样 v-bind:class=&q ...
- socket编程学习
socket: 也称作套接字,应用程序通常通过套接字向网络发出请求或者应答网络请求. 常用的套接字API函数: 1.socket(): 函数原型为:int socket(int domain, int ...
- Linux学习笔记(7)Linux常用命令之压缩解压命令
(1)gzip gzip命令用于压缩文件,英文原意为GNU zip,所在路径/bin/gzip,其语法格式为: gzip [文件] 压缩后的文件格式为.gz. 例:将/etc目录下的services文 ...
- html css js 一些记录.
webstorm 的基本使用 webstorm 格式化 html 代码: Ctrl+Alt+L js html css 基本使用 注意 dom 的 innerHTML会刷新dom,所以里面包含的事件绑 ...