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 ...
随机推荐
- 为wordpress添加Canonical标签
在 WordPress 2.9 之前,让 WordPress 博客支持 Canonical 标签是需要通过插件或者手工修改主题的 header.php 文件来实现.如在主题中加如下的代码: <? ...
- 汉诺塔问题II(模拟)
汉诺塔问题II Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1556 Solved: 720 Description 汉诺塔(又称河内塔)问题是源于 ...
- PHP常量PHP_SAPI与函数php_sapi_name()简介,PHP运行环境检测
php_sapi_name() 是用来检测PHP运行环境的函数. 该函数返回一个描述PHP与WEB服务器接口的小写字符串. 例如:aolserver, apache,apache2filter, ap ...
- Twelfth scrum meeting 2015/11/9
第一阶段的开发即将结束,工程代码已经集合完毕,计划在2015年11月10日发布第一阶段的成果,本次会议主要商量下一阶段需要完成的工作以及页面修改,还有测试人员的bug整理. 会议记录: 第一项:界面修 ...
- 【Android代码片段之六】Toast工具类(实现带图片的Toast消息提示)
转载请注明出处,原文网址:http://blog.csdn.net/m_changgong/article/details/6841266 作者:张燕广 实现的Toast工具类ToastUtil封装 ...
- iOS文件存储路径规定
Storing Your App’s Data Efficiently https://developer.apple.com/icloud/documentation/data-storage/in ...
- [BZOJ2303][Apio2011]方格染色
[BZOJ2303][Apio2011]方格染色 试题描述 Sam和他的妹妹Sara有一个包含n × m个方格的 表格.她们想要将其的每个方格都染成红色或蓝色. 出于个人喜好,他们想要表格中每个2 × ...
- Stanford机器学习---第八讲. 支持向量机SVM
原文: http://blog.csdn.net/abcjennifer/article/details/7849812 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回 ...
- Leetcode 之Convert Sorted List to Binary Search Tree(55)
和上题思路基本一致,不同的地方在于,链表不能随机访问中间元素. int listLength(ListNode* node) { ; while (node) { n++; node = node-& ...
- The CompilerVersion constant identifies the internal version number of the Delphi compiler.
http://delphi.wikia.com/wiki/CompilerVersion_Constant The CompilerVersion constant identifies the in ...