时间限制: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的更多相关文章

  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. American Football Vocabulary!

    American Football Vocabulary! Share Tweet Share You’ll learn all about the vocabulary of American fo ...

  3. 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 ...

  4. 【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&倒装句(Reduced Clauses、Inverted Sentences) 【完结】

    [英语魔法俱乐部——读书笔记] 3 高级句型-简化从句&倒装句(Reduced Clauses.Inverted Sentences):(3.1)从属从句简化的通则.(3.2)形容词从句简化. ...

  5. 【英语魔法俱乐部——读书笔记】 1 初级句型-简单句(Simple Sentences)

    第一部分 1 初级句型-简单句(Simple Sentences):(1.1)基本句型&补语.(1.2)名词短语&冠词.(1.3)动词时态.(1.4)不定式短语.(1.5)动名词.(1 ...

  6. UVa1161 Objective: Berlin(最大流)

    题目 Source https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...

  7. 11039 - Building designing

      Building designing  An architect wants to design a very high building. The building will consist o ...

  8. Top 10 Universities for Artificial Intelligence

    1. Massachusetts Institute of Technology, Cambridge, MA Massachusetts Institute of Technology is a p ...

  9. 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 ...

随机推荐

  1. Nginx 开启PATHINFO支持ThinkPHP框架实例

    ThinkPHP支持通过PATHINFO和URL rewrite的方式来提供友好的URL,只需要在配置文件中设置 'URL_MODEL' => 2 即可.在Apache下只需要开启mod_rew ...

  2. HTML中的IE条件注释

    IE条件注释是一种特殊的HTML注释,这种注释只有IE5.0及以上版本才能理解.比如普通的HTML注释是: <!--This is a comment--> 而只有IE可读的IE条件注释是 ...

  3. js打印(控件)及多种方式

    非常好用的LODOP打印控件 Lodop打印控件简单使用方法 1.安装. 2.调用LodopFuncs.js文件. 3.增加OBJECT对象 <script language="jav ...

  4. HDU 1513 Palindrome(最长公共子序列)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1513 解题报告:给定一个长度为n的字符串,在这个字符串中插入最少的字符使得这个字符串成为回文串,求这个 ...

  5. ios5之后arc的问题

    原创: 自从ios5以后, apple官方引进了ARC (automaically reference count 自动索引计数) 这个新特性, 简单的说就是对象设置为nil(空引用)之后, 当自动索 ...

  6. vim中的查找和替换

    (文章是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com) 查找: Gsearch -F 'aa' -R  --include=*rb 替换: (1)在查找结果 ...

  7. 删除重复的字符(给一个字符串,删除连续重复的字符,要求时间复杂度为O(1)……)

    // singal.cpp : Defines the entry point for the console application.// #include "stdafx.h" ...

  8. DButils实现查询和新增

             public static Adttendance DBSql(String data) throws SQLException {     String url = "j ...

  9. A desmos graph supersampling test

  10. git无法clone远程代码库及git代理设置

    git作为一个版本管理神器,日常工作中自然也就少不了了:特别是Android开发,github和google是逃不过的了.然而很多时候需要用到git克隆远程的代码库,众所周知的原因google.and ...