Poj 2349 Arctic Network 分类: Brush Mode 2014-07-20 09:31 93人阅读 评论(0) 收藏
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 9557 | Accepted: 3187 |
Description
and some outposts will in addition have a satellite channel.
Any two outposts with a satellite channel can communicate via the satellite, regardless of their location. Otherwise, two outposts can communicate by radio only if the distance between them does not exceed D, which depends of the power of the transceivers.
Higher power yields higher D but costs more. Due to purchasing and maintenance considerations, the transceivers at the outposts must be identical; that is, the value of D is the same for every pair of outposts.
Your job is to determine the minimum D required for the transceivers. There must be at least one communication path (direct or indirect) between every pair of outposts.
Input
coordinates of each outpost in km (coordinates are integers between 0 and 10,000).
Output
Sample Input
1
2 4
0 100
0 300
0 600
150 750
Sample Output
212.13
代码如下:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<stack>
using namespace std;
double map[505][505];
int dx[505][2];
double ad[255005];
int n, m; double cl(int x, int y,int k , int l )
{
double a = x;
double b = y;
double c = k;
double d = l;
return sqrt((a-c)*(a-c)+(b-d)*(b-d));
} int prim()
{
int i, j, k, s = 0;
double dis[505]={0};
int vis[505]={0};
dis[0] = 200000;
vis[1] = 1;
for(i=1;i<=m;i++) dis[i]=map[1][i];
for(i=1;i<m;i++)
{
k = 0;
for(j=1;j<=m;j++)
{
if(dis[j]<dis[k] && vis[j]==0 && dis[j]) k = j;
}
vis[k] = 1;
ad[s++]=dis[k];
for(j=1;j<=m;j++)
{
if(vis[j]) continue;
if((dis[j]>map[k][j] || dis[j]==0 ) && map[k][j] ) dis[j]=map[k][j];
}
}
return s;
} int main()
{
int a, b, c, key;
// freopen("in.txt","r+",stdin);/*如果in.txt不在连接后的exe的目录,需要指定路径如D:\\in.txt*/
// freopen("out.txt","w+",stdout);/*同上*/
scanf("%d",&key);
while(key--)
{
memset(map,0,sizeof(map));
memset(map,0,sizeof(dx));
memset(map,0,sizeof(ad));
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
scanf("%d%d",&a,&b);
dx[i][0] = a;
dx[i][1] = b;
} for(int i=1;i<=m;i++)
{
for(int j=i;j<=m;j++)
{
map[i][j] = map[j][i] = cl(dx[i][0],dx[i][1],dx[j][0],dx[j][1]);
}
} // for(int i=1;i<=m;i++)
// {
// for(int j=1;j<=m;j++) printf("%lf ",map[i][j]);
// printf("\n");
// } prim();
sort(ad,ad+m-1);
printf("%.2lf\n",ad[m-n-1]);
}
// fclose(stdin);
// fclose(stdout); return 0;
}
请选择C++编译器,不要选择G++,这就是为什么你WA的主要原因
论G++与C++的区别
版权声明:本文为博主原创文章,未经博主允许不得转载。
Poj 2349 Arctic Network 分类: Brush Mode 2014-07-20 09:31 93人阅读 评论(0) 收藏的更多相关文章
- Poj 1050 分类: Translation Mode 2014-04-04 09:31 103人阅读 评论(0) 收藏
To the Max Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 39058 Accepted: 20629 Desc ...
- 修改MS SQL忽略大小写 分类: SQL Server 数据库 2015-06-19 09:18 34人阅读 评论(0) 收藏
第一步:数据库->属性->选项->限制访问:SINGLE_USER 第二步:ALTER DATABASE [数据库名称] collate Chinese_PRC_CI_AI 第三步: ...
- *** glibc detected *** malloc(): memory corruption 分类: C/C++ Linux 2015-05-14 09:22 37人阅读 评论(0) 收藏
*** glibc detected *** malloc(): memory corruption: 0x09eab988 *** 发现是由于memset越界写引起的. 在Linux Server上 ...
- sscanf 函数 分类: POJ 2015-08-04 09:19 4人阅读 评论(0) 收藏
sscanf 其实很强大 分类: 纯C技术 技术笔记 2010-03-05 16:00 12133人阅读 评论(4) 收藏 举报 正则表达式stringbuffercurlgoogle 最近在做日志分 ...
- Poj 2528 Mayor's posters 分类: Brush Mode 2014-07-23 09:12 84人阅读 评论(0) 收藏
Mayor's posters Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 40570 Accepted: 11798 ...
- Hdu 1507 Uncle Tom's Inherited Land* 分类: Brush Mode 2014-07-30 09:28 112人阅读 评论(0) 收藏
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- PIGS 分类: POJ 图论 2015-08-10 09:15 3人阅读 评论(0) 收藏
PIGS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18209 Accepted: 8277 Description Mir ...
- 哈希-4 Values whose Sum is 0 分类: POJ 哈希 2015-08-07 09:51 3人阅读 评论(0) 收藏
4 Values whose Sum is 0 Time Limit: 15000MS Memory Limit: 228000K Total Submissions: 17875 Accepted: ...
- 哈希-Gold Balanced Lineup 分类: POJ 哈希 2015-08-07 09:04 2人阅读 评论(0) 收藏
Gold Balanced Lineup Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13215 Accepted: 3873 ...
随机推荐
- MongoDB(4):多种方式关闭服务命令
http://blog.csdn.net/czw698/article/details/8791153 MongoDB 提供几种关闭服务的命令,具体为以下: 一 使用 Crtl+C 关闭 [mong ...
- psd图片到html
正确的做法是:拿到psd后,先不要做别的,直接在文本编辑器中将网页的框架写出来,不要假设这块将来css要去怎么渲染,完全自然化的标签,不加任何的css.写完之后在各个浏览器运行之后确保大体定位都没有问 ...
- 委托、匿名函数与Lambda表达式初步
(以下内容主要来自<C#本质论第三版>第十二章委托和Lambda表达式) 一.委托续 上上周五看了看委托,初步明白了其是个什么,如何定义并调用.上周五准备看Lambda表达式,结果发现C# ...
- [转]SQLServer 2008以上误操作数据库恢复方法——日志尾部备份
原文出处:http://blog.csdn.net/dba_huangzj/article/details/8491327 问题: 经常看到有人误删数据,或者误操作,特别是update和delete的 ...
- jQuery学习笔记(2)
val() 当鼠标放上去的时候,文本消失,鼠标拿开,文本恢复 效果图: code as below: <html xmlns="http://www.w3.org/1999/xhtml ...
- Linux shell用法和技巧(转)
原文出处: techbar 译文出处: 外刊IT评论 使用Linux shell是我每天的基本工作,但我经常会忘记一些有用的shell命令和技巧.当然,命令我能记住,但我不敢说能记得如何用它执行某 ...
- Maven学习随记
慕课网视频教程:http://www.imooc.com/learn/443 ====Maven是什么 Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建.报告和文档的软件 ...
- 关于iphone消息推送把C#当服务器端来发送
看了苹果消息推送文档,感觉推送很简单的,但是还是按个人习惯把这些简单知识记录下来,在需要时候再查看一下! 在开发之前,要准备以下的资料 1.证书(包括产生证书和调试证书) 2.证书密码 3.唯一标识( ...
- 【javascript】随手记代码
//js实现的当前界面的刷新.前进.后退 <input type="button" value="刷新" onclick="window.loc ...
- 使用Telerik控件搭建Doubanfm频道部分
今天感觉好累啊..还是坚持记录下. 收集的API: https://github.com/HakurouKen/douban.fm-api https://github.com/zonyitoo/do ...