Arctic Network(P2349)
来源:互联网 发布:海澜之家男装淘宝网 编辑:程序博客网 时间:2024/05/26 20:22
这个题是自己大概猜测着题意做的,
给出有几个频道,两个频道间可以用卫星传,不计算距离,这样就用PIM计算出加入的边排好序后根据S选倒数第几大的就行了,
#include<iostream>#include<stdlib.h>#include<math.h>#include<stdio.h>#include<algorithm>#include<queue>#include<string.h>#include<stack>#include<math.h>#include<stdlib.h>#include<list>#include<vector>using namespace std;double map[500][5000];int n,s;struct my{ double x; double y;}point[500];int main(){ int i,j,k; int t; cin>>t; while (t--) { cin>>s>>n; for (i=0;i<n;i++) { cin>>point[i].x>>point[i].y; } for (i=0;i<n;i++) { for (j=i+1;j<n;j++) { map[i][j]=sqrt((point[i].x-point[j].x)*(point[i].x-point[j].x)+(point[i].y-point[j].y)*(point[i].y-point[j].y)); map[j][i]=map[i][j]; } } bool vist[500]; memset(vist,false,sizeof(vist)); double ans[500]; double hi[500]; for (i=0;i<n;i++) { hi[i]=map[0][i]; } k=n-1; vist[0]=true; int l=0; while (k--) { double big=100000000.0; for (i=0;i<n;i++) { if (!vist[i]&&big>hi[i]) big=hi[i],j=i; } vist[j]=true; ans[l++]=big; //cout<<big<<endl; for (i=0;i<n;i++) { if (!vist[i]&&hi[i]>map[i][j]) hi[i]=map[i][j]; } } sort(ans,ans+l); printf("%.2f\n",ans[n-s-1]); }}
Arctic Network
Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 5310 Accepted: 1880
Description
The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio transceiver 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.
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
The first line of input contains N, the number of test cases. The first line of each test case contains 1 <= S <= 100, the number of satellite channels, and S < P <= 500, the number of outposts. P lines follow, giving the (x,y) coordinates of each outpost in km (coordinates are integers between 0 and 10,000).
Output
For each case, output should consist of a single line giving the minimum D required to connect the network. Output should be specified to 2 decimal points.
Sample Input
12 40 1000 3000 600150 750
Sample Output
212.13
Source
- Arctic Network(P2349)
- Arctic Network
- Arctic Network
- Arctic Network
- Arctic Network
- Arctic Network
- Arctic Network
- Arctic Network
- Arctic Network
- Arctic Network
- POJ 2349 Arctic Network
- UVA 10369 Arctic Network
- zoj 1914 Arctic Network
- PRIM_poj 2349Arctic Network
- uva10369 - Arctic Network
- POJ 2349 Arctic Network
- poj 2349 Arctic Network
- UVaOJ 10369 - Arctic Network
- VC 中ASCII Unicode GB2312之间的转换
- java例程练习(输出101~200以内所有的质数)
- ubuntu系统中没有/etc/inittab的问题
- SQL SERVER2000分页存储过程
- 第九周任务(五)
- Arctic Network(P2349)
- 第九周 任务1
- 九周任务3
- AOP术语概析
- Android ListView控件基本用法
- 【Android】发送Email(内置Gmail和JavaMail)
- MySQL基本命令
- AOP术语详解
- 第九周 任务2