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 ...
随机推荐
- HDU4010 Query on The Trees(LCT)
人生的第一道动态树,为了弄懂它的大致原理,需要具备一些前置技能,如Splay树,树链剖分的一些概念.在这里写下一些看各种论文时候的心得,下面的代码是拷贝的CLJ的模板,别人写的模板比较可靠也方便自己学 ...
- 解高次同余方程 (A^x=B(mod C),0<=x<C)Baby Step Giant Step算法
先给出我所参考的两个链接: http://hi.baidu.com/aekdycoin/item/236937318413c680c2cf29d4 (AC神,数论帝 扩展Baby Step Gian ...
- Android的px、dip、sp的区别
Android的px.dip.sp的区别 我们在页面布局的时候,经常会设置容器的长度,但是到底该使用哪个作为长度的单位而懊恼. 在Android中支持的描述大小区域的类型有以下几种: px(pix ...
- C#实现文件增量备份
最近将客户的一个ASP网站部署到了公司的机房云服务器上,该ASP网站的文件总容量已有将近4GB. 虽然现在硬盘容量很大,但每天一次完整备份的话,那占用的硬盘空间会急剧上升,考虑一个更优的备份方案就是每 ...
- T_SQL基于列的逻辑表达式(case)
本文摘自:http://www.cnblogs.com/kissdodog/p/3154371.html(感谢作者的分享,总结的很好) 基于列的逻辑表达式,其实就是CASE表达式.可以用在SELECT ...
- UVA 10943 How do you add? DP
Larry is very bad at math — he usually uses a calculator, whichworked well throughout college. Unfor ...
- Struts2 Convention插件的使用(1)
刚刚查阅官方文档(convention-plugin.html)并学习了Struts2的Convention插件,文章这里只作为一个笔记,建议大家去看官方文档比较清晰和全面. 需要在项目添加这些包 c ...
- java编译错误:varargs 方法的非 varargs 调用
转自:http://www.blogjava.net/ideame/archive/2007/03/23/105849.html 警告: 最后一个参数使用了不准确的变量类型的 varargs 方法的非 ...
- JAVA实现Excel导出数据(以写好的Excel模版导出)
工作中经常会有将后台数据以Excel导出的功能. 简单的方法有将response的contentType设置为application/vnd.ms-excel: 或在JSP页面直接设置成: <% ...
- asyn4j -- java 异步方法调用框架
asyn4j 是一个java异步方法调用框架,基于消费者与生产者模式.包括了异步方法执行,异步回调执行,异步工作缓存模块.支持Spring. 让我们写异步方法不再写很多的相关多线程代码.用asyn4j ...