codeforces 431 B Shower Line【暴力】
题意:给出五个人的编号,分别为 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【暴力】的更多相关文章
- [codeforces 549]G. Happy Line
[codeforces 549]G. Happy Line 试题描述 Do you like summer? Residents of Berland do. They especially love ...
- codeforces B. Shower Line 解题报告
题目链接:http://codeforces.com/contest/431/problem/B 题目意思:给出5 * 5 的矩阵.从这个矩阵中选出合理的安排次序,使得happiness之和最大.当第 ...
- Codeforces Round #247 (Div. 2) B - Shower Line
模拟即可 #include <iostream> #include <vector> #include <algorithm> using namespace st ...
- Codeforces Gym 100015H Hidden Code 暴力
Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hac ...
- Codeforces gym 100685 A. Ariel 暴力
A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Desc ...
- Codeforces Gym 100637G G. #TheDress 暴力
G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G ...
- Codeforces 626D Jerry's Protest(暴力枚举+概率)
D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- codeforces 650D D. Image Preview (暴力+二分+dp)
题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memo ...
- 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 ...
随机推荐
- IT架构之IT架构标准——思维导图
参考: [日] 野村综合研究所系统咨询事业本部. 图解CIO工作指南. 周自恒译 人民邮电出版社,2014
- HDU3507 Print Article(斜率优化dp)
前几天做多校,知道了这世界上存在dp的优化这样的说法,了解了四边形优化dp,所以今天顺带做一道典型的斜率优化,在百度打斜率优化dp,首先弹出来的就是下面这个网址:http://www.cnblogs. ...
- String Reduction
问题出自这里 问题描述: Given a string consisting of a,b and c's, we can perform the following operation: Take ...
- Linux客户/服务器程序设计范式2——并发服务器(进程池)
引言 让服务器在启动阶段调用fork创建一个子进程池,通过子进程来处理客户端请求.子进程与父进程之间使用socketpair进行通信(为了方便使用sendmsg与recvmsg,如果使用匿名管道,则无 ...
- Jenkins+Maven+Git CI环境搭建手册
Jenkins+Maven+Git CI环境搭建手册 环境: OS:Linux version 2.6.32-220.23.2.ali878.el6.x86_64 (ads@kbuild) (gcc ...
- 李洪强漫谈iOS开发[C语言-042]-简单计算器
李洪强漫谈iOS开发[C语言-042]-简单计算器
- 李洪强iOS经典面试题12
1.说说响应链 答: 事件响应链.包括点击事件,画面刷新事件等.在视图栈内从上至下,或者从下之上传播. 可以说点事件的分发,传递以及处理.具体可以去看下touch事件这块.因为问的太抽象化了 严重怀 ...
- 好玩的算法(JS版)
1.字符串反转 'cba'.split('').reverse().join(''); 2.在数组最后一位添加一项 array[array.length]=(new value);
- LR_问题_平均响应时间解释,summary与analysis不一致
Summary Report中的时间说明 Summary是按整个场景的时间来做平均的,最大最小值,也是从整个场景中取出来的. (1) 平均响应时间:事物全部响应时间做平均计算 (2) ...
- CentOS安装Chrome
问题 在CentOS安装Chrome会遇到 libstdc++.so.6(GLIBCXX_3.4.15)(64bit) 依赖失败的问题, 即使下载了最新的libstdc++.so.6(包含GLIBCX ...