Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <queue>
- #include <iostream>
- #include <vector>
- #include <cstring>
- #include <iostream>
- //#include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- vector < pair<int,int> > v;
- int x,y;
- for(int i=0;i<n;i++)
- {
- cin>>x>>y;
- v.push_back(make_pair(x,y));
- }
- vector < pair<int, double> > g[n];
- vector<bool> visited(n,false);
- vector<double> dis(n,-2e9);
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<n;j++)
- {
- double d=sqrt(((v[j].first-v[i].first) * (v[j].first-v[i].first))+((v[j].second-v[i].second)*(v[j].second-v[i].second)));
- if(d<=10)
- g[i].push_back(make_pair(j,-d));
- }
- }
- dis[0]=0;
- priority_queue<pair<double, int> > pq;
- pq.push(make_pair(0,0));
- while(!pq.empty())
- {
- pair<double, int> c=pq.top();
- pq.pop();
- if(visited[c.second])
- {
- continue;
- }
- visited[c.second]=true;
- for(int i=0;i<g[c.second].size();i++)
- {
- int s=g[c.second][i].first;
- double t=g[c.second][i].second;
- if(!visited[s] && c.first+t>dis[s])
- {
- pq.push(make_pair(c.first+t, s));
- dis[s]=c.first+t;
- }
- }
- }
- cout<<-dis[n-1]<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement