UVAlive 6623 Battle for Silver(暴力+思路)
来源:互联网 发布:怎样用js做用户名验证 编辑:程序博客网 时间:2024/06/08 10:03
题目地址:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4634
思路:图中两条边之间不能交叉,则最终的选择的点集中的点只能有1,2,3,4个,暴力枚举即可。
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;const int maxn=1000;const int INF=0x3f3f3f3f;struct Node{ int x,y; Node(int x=0,int y=0):x(x),y(y){}};int n,m;int w[maxn];Node p[maxn];int g[maxn][maxn];int main(){ while(scanf("%d%d",&n,&m)!=EOF) { int ans=-INF; memset(g,0,sizeof(g)); for(int i=1;i<=n;i++) { scanf("%d",&w[i]); ans=max(ans,w[i]); } for(int i=1;i<=m;i++) { int u,v; scanf("%d%d",&u,&v); p[i]=Node(u,v); g[u][v]=1,g[v][u]=1; ans=max(ans,w[u]+w[v]); } for(int i=1;i<=m;i++) { int u=p[i].x,v=p[i].y; for(int j=1;j<=n;j++) { if(g[u][j]&&g[v][j]) ans=max(ans,w[u]+w[v]+w[j]); } } for(int i=1;i<=m;i++) for(int j=1;j<=m;j++) { int u1=p[i].x,v1=p[i].y; int u2=p[j].x,v2=p[j].y; if(g[u1][u2]&&g[u1][v2]&&g[u2][v1]&&g[v1][v2]) ans=max(ans,w[u1]+w[v1]+w[u2]+w[v2]); } printf("%d\n",ans); } return 0;}
0 0
- UVAlive 6623 Battle for Silver(暴力+思路)
- UESTC889&&uvalive6623 Battle for Silver(dfs)
- UESTC 889 Battle for Silver (dfs)
- nwerc2013 B - Battle for Silver
- ACM Battle(巧妙暴力)
- UVALive 6852Blanket(暴力)
- UVALive 6895Deduction(暴力)
- UVALive 6089 Nine (暴力模拟)
- UVALive - 5908(UVA1517)Tracking RFIDs(暴力)
- UVALive 6907Body Building(暴力)
- UVALive 6621 Pocket Cube(暴力)
- UVALive 6692 Lucky Number (思路 + 枚举)
- UVALive 7464 - Robots (思路+模拟)
- Sea Battle<海战>(思路题)
- UVALive - 2963 Hypertransmission 暴力
- uvalive 4253(暴力)
- UVALive - 4253 Archery 暴力
- UVALive 6924 暴力
- 数据结构实验之排序三:bucket sort
- 黄阶低级 - 《 Java 核心》- 4.6 对象构造 - 修改0次
- 彻底理解webservice SOAP WSDL
- POJ 2352 Stars(树状数组)
- nyoj-1261-音痴又音痴的LT【思维】
- UVAlive 6623 Battle for Silver(暴力+思路)
- TCP-心跳
- Leetcode 385. Mini Parser
- QRCode生成二维码和解析二维码
- 数据结构实验之二叉树六:哈夫曼编码
- 使用wifi网卡笔记3---工具wpa_supplicant(STA模式)
- MAC OS 安装pip
- UI基础学习05
- 计算机网络-应用层