17111 Football team
时间限制:1000MS 内存限制:65535K
提交次数:0 通过次数:0
题型: 编程题 语言: C++;C
Description
As every one known, a football team has 11 players . Now, there is a big problem in front of the Coach Liu. The final contest is getting closer.
Who is the center defense, the full back or the forward? ...... There are n wonderful players for n positions in the team and Coach Liu know
everyone's abilities at different positions in matches. Assume that the team's power is the sum of the abilities of all n players according to
their positions, could you help Coach Liu to find out the max power his team can get?
输入格式
The first line is an integer n(n<11). Followed by n rows. Each row has n integer (0 to 1000) which represents the abilities of one player
at different positions.
输出格式
The max power.
输入样例
10
4 6 3 3 4 5 7 4 9 0
5 9 3 4 6 1 7 3 9 3
1 5 8 0 5 4 2 7 9 3
4 6 9 4 7 3 7 9 5 4
2 0 1 3 2 5 8 4 6 2
1 5 8 4 2 6 8 0 4 2
1 4 2 6 8 9 4 2 6 8
1 2 9 5 6 4 2 7 5 7
2 4 7 5 8 5 3 2 6 4
2 4 6 4 8 7 3 5 7 3
输出样例
76 简单回溯:wa在由于now是全局变量,在每一次到达结束状态时,now的值不会因递归返回而改变(不像局部变量),而我是希望在递归枚举所有情况是now的值应该是返回上一状态的,
故因 加一句:now-=mat[i][j]
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int mat[12][12];
int vis[12];
int now=0;
int maxr=0;
void dfs(int cur)
{
int i;
if(cur==n) {if(now>maxr) maxr=now;}
else for(i=0;i<10;++i){
if(!vis[i]){
now+=mat[cur][i];//尝试选择第cur行第i列的数
vis[i]=1;
dfs(cur+1);
vis[i]=0;
now-=mat[cur][i];//谨记,now需随递归返回原来的值
} }
}
int main()
{
memset(vis,0,sizeof(vis));
memset(mat,0,sizeof(mat));
scanf("%d",&n);
for(int i=0;i<n;++i)
for(int j=0;j<n;++j)
scanf("%d",&mat[i][j]);
dfs(0);
printf("%d\n",maxr);
}
17111 Football team的更多相关文章
- WOJ 124. Football Coach 网络流
Problem 1124 - Football Coach Description It is not an easy job to be a coach of a football team. Th ...
- American Football Vocabulary!
American Football Vocabulary! Share Tweet Share You’ll learn all about the vocabulary of American fo ...
- ZOJ Problem Set – 2321 Filling Out the Team
Time Limit: 2 Seconds Memory Limit: 65536 KB Over the years, the people of the great city of Pi ...
- 【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&倒装句(Reduced Clauses、Inverted Sentences) 【完结】
[英语魔法俱乐部——读书笔记] 3 高级句型-简化从句&倒装句(Reduced Clauses.Inverted Sentences):(3.1)从属从句简化的通则.(3.2)形容词从句简化. ...
- 【英语魔法俱乐部——读书笔记】 1 初级句型-简单句(Simple Sentences)
第一部分 1 初级句型-简单句(Simple Sentences):(1.1)基本句型&补语.(1.2)名词短语&冠词.(1.3)动词时态.(1.4)不定式短语.(1.5)动名词.(1 ...
- UVa1161 Objective: Berlin(最大流)
题目 Source https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- 11039 - Building designing
Building designing An architect wants to design a very high building. The building will consist o ...
- Top 10 Universities for Artificial Intelligence
1. Massachusetts Institute of Technology, Cambridge, MA Massachusetts Institute of Technology is a p ...
- What am I missing out in life if I don't have a girlfriend?
http://www.quora.com/What-am-I-missing-out-in-life-if-I-dont-have-a-girlfriend/answer/Kelly-Erickson ...
随机推荐
- CSS包含块containing block详解
“包含块(containing block)”,W3c中一个很重要的概念,今天带大家一起来好好研究下. 初步理解 在 CSS2.1 中,很多框的定位和尺寸的计算,都取决于一个矩形的边界,这个矩形,被称 ...
- 异常:The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application
The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml ...
- 细微之处:比较两种CSS清除浮动的兼容
http://www.cnblogs.com/bienfantaisie/archive/2011/05/27/2059597.html 清除浮动是连续浮动元素之后的必备工作,在工作中我做到需要清除浮 ...
- php远程抓取网站图片并保存
以前看到网上别人说写程序抓取网页图片的,感觉挺神奇,心想什么时候我自己也写一个抓取图片的方法! 刚好这两天没什么事,就参考了网上一个php抓取图片代码,重点借鉴了 匹配img标签和其src属性正则的写 ...
- java中四种阶乘的计算
package com.zf.s2;//创建一个包 import java.math.BigInteger;//导入类 import java.util.ArrayList; import jav ...
- encode和decode
Python字符串的encode与decode研究心得乱码问题解决方法 为什么会报错“UnicodeEncodeError: 'ascii' codec can't encode characters ...
- springMVC获取file,几种转换
//从前台通过name值获取file MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)reque ...
- ORACLE查询当前资产状态,和另一个数据库联查,(查询重复数据中第一条),子查询作为字段查询
背景:ORACLE查询当前资产状态,包含资产信息(表1),资产维修状态(表2),资产报废状态(表3) 如下: 资产信息:
- Mysql常用函数列举
1,HEX(),十六进制转化;eg:select HEX('mysql'); select X'6D7973716C'; 2,bit_count(),计算二进制数中包含1的个数;bit_or(),对两 ...
- Fresco 源码分析(一) DraweeView-DraweeHierarchy-DraweeController(MVC) DraweeView的分析
4. Fresco的内容 为了方便学习,我们先从使用结合官方的文档来分析 4.1 Fresco客户端的使用 在使用Fresco的使用,我们直接使用的是SimpleDraweeView这个类,然后在Ac ...