PAT 1072. Gas Station
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range.
Now given the map of the city and several candidate locations for the gas station, you are supposed to give the best recommendation. If there are more than one solution, output the one with the smallest average distance to all the houses. If such a solution is still not unique, output the one with the smallest index number.
Input Specification:
Each input file contains one test case. For each case, the first line contains 4 positive integers: N (<= 103), the total number of houses; M (<= 10), the total number of the candidate locations for the gas stations; K (<= 104), the number of roads connecting the houses and the gas stations; and DS
Then K lines follow, each describes a road in the format
P1 P2 Dist
where P1 and P2 are the two ends of a road which can be either house numbers or gas station numbers, and Dist is the integer length of the road.
Output Specification:
For each test case, print in the first line the index number of the best location. In the next line, print the minimum and the average distances between the solution and all the houses. The numbers in a line must be separated by a space and be accurate up to 1 decimal place. If the solution does not exist, simply output “No Solution”.
Sample Input 1:4 3 11 5 1 2 2 1 4 2 1 G1 4 1 G2 3 2 3 2 2 G2 1 3 4 2 3 G3 2 4 G1 3 G2 G1 1 G3 G2 2Sample Output 1:
G1 2.0 3.3Sample Input 2:
2 1 2 10 1 G1 9 2 G1 20Sample Output 2:
No Solution
相關推薦
PAT 1072 Gas Station (30)
esp 狀態 solution sam 不知道 specific 解決方案 sep ans A gas station has to be built at such a location that the minimum distance between the stat
PAT 1072. Gas Station
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possi
PAT 1072. Gas Station (30)(多個點的最短路徑)
官網 1072. Gas Station (30) 時間限制 200 ms 記憶體限制 65536 kB 程式碼長度限制 16000 B 判題程式 Standard 作者 CHEN, Yue A gas station has to
PAT甲級 1072 Gas Station (30 分)Dijkstra
1072 Gas Station (30 分) A gas station has to be built at such a location that the minimum distance between the station and any of the res
PAT (Advanced Level) Practice 1072 Gas Station (30 分)
程式設計題 1072 Gas Station (30 分) A gas station has to be built at such a location that the minimum distance between the station and any of t
【PAT】1072. Gas Station (30)【dijkstra演算法】
題目描述 A gas station has to be built at such a location that the minimum distance between the station and any of the residential hou
PAT-ADVANCED1072——Gas Station
我的PAT-ADVANCED程式碼倉:https://github.com/617076674/PAT-ADVANCED 原題連結:https://pintia.cn/problem-sets/994805342720868352/problems/994805396953219072
1072 Gas Station (30 分)(最短路徑)
#include<bits/stdc++.h> using namespace std; const int N=1e3+100; int n,m,k,Ds; int mp[N][N]; int dis[N]; int vis[N]; int inf=0x3f3f3f3
PAT A1072 Gas Station(30 分)-------圖最短路徑---比較難點的題
總結: 1.這道題用了dijstra演算法,關鍵是開始對G1非數字的處理即Gi處理成i+n;我最後一個測試點開始沒過就是因為用s.size()判斷輸入為數字還是G2,但是其實資料n+m是大於99的 程式碼: #include<iostream> #include<alg
PAT A1072. Gas Station
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as
leetcode 刷題之路 68 Gas Station
rom 說明 之路 bsp margin tom otto mono lee There are N gas stations along a circular route, where the amount of gas at station i is gas[i]
134. Gas Station
下一個 tar travel emp pan col ons -c amount There are N gas stations along a circular route, where the amount of gas at station i is gas[i].
[leetcode]134. Gas Station加油站
CA ise 如何 ring exists log public 積累 www There are N gas stations along a circular route, where the amount of gas at station i is gas[
LeetCode:134. Gas Station(Week 7)
134. Gas Station 題目 There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an
LeetCode 134 Gas Station
LeetCode 134 Gas Station 水題,暴力一下就ok class Solution { public: int tag[100005]; int sum[100005]; int canCompleteCircuit(vector<int>&
PAT-1072 開學寄語
1072 開學寄語 (20 分) 下圖是上海某校的新學期開學寄語:天將降大任於斯人也,必先刪其微博,卸其 QQ,封其電腦,奪其手機,收其 ipad,斷其 wifi,使其百無聊賴,然後,淨面、理髮、整衣,然後思過、讀書、鍛鍊、明智、開悟、精進。而後必成大器也! 本題要求你寫個程式幫助
[Swift]LeetCode134. 加油站 | Gas Station
uniq plan journey 汽車 other direct with nbsp require There are N gas stations along a circular route, where the amount of gas at station i
[Leetcode 134]汽車加油站 Gas Station (圈形)
【題目】 There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unl
leetcode 134. Gas Station
leetcode 134. Gas Station 題目: There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a ca
PAT 1072
1072 開學寄語 (20 分) 下圖是上海某校的新學期開學寄語:天將降大任於斯人也,必先刪其微博,卸其 QQ,封其電腦,奪其手機,收其 ipad,斷其 wifi,使其百無聊賴,然後,淨面、理髮、整衣,然後思過、讀書、鍛鍊、明智、開悟、精進。而後必成大器也! 本題要求