Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iostream>
- #include <climits>
- #include <vector>
- using namespace std;
- double find_dist(int x1, int y1, int x2, int y2)
- {
- return(sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)));
- }
- int main()
- {
- int n, m;
- double d;
- cin >> n;
- double dist[n+1][n+1];
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < n; j++)
- {
- dist[i][j] = INT_MAX-1;
- }
- dist[i][i] = 0;
- }
- int t1, t2, tw;
- vector< pair<int, int> > adj(n);
- for(int i = 0; i < n; i++)
- {
- cin >> t1 >> t2;
- adj[i].first = t1;
- adj[i].second = t2;
- }
- for(int i = 0; i < n-1; i++)
- {
- for(int j = i+1; j < n; j++)
- {
- //double d = abs(adj[i].first - adj[j].first) + abs(adj[i].second - adj[j].second);
- double dt = find_dist(adj[i].first, adj[i].second, adj[j].first, adj[j].second);
- //cout << dt << endl;
- if(dt <= 10.0)
- dist[i][j] = dist[j][i] = dt;
- }
- }
- for(int k = 0; k < n; k++)
- {
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < n; j++)
- {
- d = dist[i][k] + dist[k][j];
- if(d < dist[i][j])
- {
- dist[i][j] = d;
- }
- }
- }
- }
- int rez = -1;
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < n; j++)
- {
- //cout << dist[i][j] << " ";
- if(dist[i][j] > rez)
- rez = dist[i][j];
- }
- // cout << endl;
- }
- if(rez == INT_MAX-1)
- cout << "NE"<< endl;
- else
- cout << rez << endl;
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement