Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //UVa Q534
- #include <bits/stdc++.h>
- using namespace std;
- struct stat{
- int idx;
- double dist;
- bool operator>(const stat x)const{return dist > x.dist;}
- bool operator<(const stat x)const{return dist < x.dist;}
- };
- struct pt{
- int x,y;
- }arr[200];
- bool vis[200];
- double calc(pt a, pt b){
- return sqrt((a.x-b.x) * (a.x-b.x) + (a.y-b.y) * (a.y-b.y));
- }
- int32_t main(){
- int n, cnt = 0;
- while(cin >> n){
- if(n == 0)break;
- for(int i = 0; i < n; ++i)cin >> arr[i].x >> arr[i].y;
- memset(vis, 0, sizeof(vis));
- priority_queue<stat, deque<stat>, greater<stat>> pq;
- stat tmd = {.idx = 0, .dist = 0};
- pq.push(tmd);
- double ans;
- while(!pq.empty()){
- tmd = pq.top();
- pq.pop();
- vis[tmd.idx] = 1;
- if(tmd.idx == 1){
- ans = tmd.dist;
- break;
- }
- for(int i = 0; i < n; ++i){
- if(!vis[i]){
- stat nxt = {.idx = i, .dist = max(tmd.dist, calc(arr[tmd.idx], arr[i]))};
- pq.push(nxt);
- }
- }
- }
- cout << "Scenario #" << ++cnt << endl;
- printf("Frog Distance = %.3f\n\n", ans);
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement