题意:给出五个人的编号,分别为 1 2 3 4 5,他们在排队,

最开始的时候,1和2可以交谈,3和4可以交谈 然后1走了之后,2和3交谈,4和5可以交谈 2走了之后,3和4可以交谈, 3走了之后,4和5可以交谈

给出一个5*5的矩阵,问最大的交谈的值, 比如2和3交谈,交谈的值为g[2][3]+g[3][2]

直接枚举排列,因为5!=120,算出每一种排列的交谈值,找出最大值

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std; typedef long long LL;
const int INF = (<<)-;
const int mod=;
const int maxn=; int g[][]; int main(){
int n,a[]={,,,,};
n=;
int p[]; for(int i=;i<=;i++)
for(int j=;j<=;j++) cin>>g[i][j]; int ans=;
int maxx=-;
do{
for(int i=;i<;i++) {
// printf("%d ",a[i]);
p[i]=a[i];
} // printf("\n");
int a=g[p[]][p[]]+g[p[]][p[]]+g[p[]][p[]]+g[p[]][p[]];
int b=g[p[]][p[]]+g[p[]][p[]]+g[p[]][p[]]+g[p[]][p[]];
int c=g[p[]][p[]]+g[p[]][p[]];
int d=g[p[]][p[]]+g[p[]][p[]];
ans=a+b+c+d;
maxx=max(ans,maxx);
// printf("maxx=%d\n",maxx);
// printf("ans=%d\n",ans); } while(next_permutation(a,a+)); printf("%d\n",maxx);
return ;
}

codeforces 431 B Shower Line【暴力】的更多相关文章

  1. [codeforces 549]G. Happy Line

    [codeforces 549]G. Happy Line 试题描述 Do you like summer? Residents of Berland do. They especially love ...

  2. codeforces B. Shower Line 解题报告

    题目链接:http://codeforces.com/contest/431/problem/B 题目意思:给出5 * 5 的矩阵.从这个矩阵中选出合理的安排次序,使得happiness之和最大.当第 ...

  3. Codeforces Round #247 (Div. 2) B - Shower Line

    模拟即可 #include <iostream> #include <vector> #include <algorithm> using namespace st ...

  4. Codeforces Gym 100015H Hidden Code 暴力

    Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hac ...

  5. Codeforces gym 100685 A. Ariel 暴力

    A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Desc ...

  6. Codeforces Gym 100637G G. #TheDress 暴力

    G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G ...

  7. Codeforces 626D Jerry's Protest(暴力枚举+概率)

    D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...

  8. codeforces 650D D. Image Preview (暴力+二分+dp)

    题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memo ...

  9. Codeforces 839D Winter is here - 暴力 - 容斥原理

    Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n s ...

随机推荐

  1. Sqli-labs less 19

    Less-19 从源代码中我们可以看到我们获取到的是HTTP_REFERER 那和less18是基本一致的,我们从referer进行修改. 还是像less18一样,我们只给出一个示例 将referer ...

  2. 时序列数据库武斗大会之 OpenTSDB 篇

    [编者按] 刘斌,OneAPM后端研发工程师,拥有10多年编程经验,参与过大型金融.通信以及Android手机操作系的开发,熟悉Linux及后台开发技术.曾参与翻译过<第一本Docker书> ...

  3. ZOJ 3555 Ice Climber(dp)

    晦涩的题意+各种傻逼害我调了那么久,实际上题目就是一个dp[i][j],dp[i][j]表示第i层第j个最少需要多少时间,当我们去更新dp[i][j]的时候,考虑的是从第i+1层的某一个dp[i+1] ...

  4. java EE 5 Libraries 删掉后怎么重新导入

    (1)Add Library   中  MyEclipse Libraries (2)输入 java  即可找到 问题解决.

  5. Xamarin for Visual Studio 3.11.666 Beta版 破解补丁

    注意:本版本是 Beta 版   现已推送到稳定频道 前提概要 全新安装请参考 安装 Xamarin for Visual Studio. 最新稳定版请参考 Xamarin for Visual St ...

  6. x86虚拟地址到物理地址的映射学习

    这里只谈分页管理的机制,也是目前最重要的内存管理机制. 最初的设计想法: 结构图如下: 页的尺寸是4KB,虚拟地址的前20位用于指定一个物理页,后12位用于访问页内偏移. 页表项的结构: 各个位的含义 ...

  7. springmvc的系统学习之配置方式

    资源:尚学堂  邹波 springmvc框架视频  一.springMVC 工作流程        页面请求---->控制器(Controller DispatcherServlet)----& ...

  8. 基于ant的jmeter自动化性能测试

    准备工作: 1.java的运行环境正常,及运行java -version.javac -version能正常输出java版本: 2.ant的运行环境正常,使用ant需要配置环境变量,编辑/etc/pr ...

  9. lintcode:数字组合 II

    数字组合 II 给出一组候选数字(C)和目标数字(T),找出C中所有的组合,使组合中数字的和为T.C中每个数字在每个组合中只能使用一次. 注意事项 所有的数字(包括目标数字)均为正整数. 元素组合(a ...

  10. 2016网易实习生编程题:数组中两个数的和等于sum

    题目 找出数组中两个数的和等于sum的这两个数 解题 这个题目做过很多次了,利用HashMap,key为 sum-A[i] value为 i 当 加入HashMap时候A[i] 已经存在map中,ge ...