E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
1072
1072
.Gas Station
【题意】找一个到所有房屋最短距离最远,平均距离最近,且覆盖所有房屋的加油站【思路】把住房和加油站都视作普通节点,对每个加油站用一次Dijkstra算法即可【注意点】此题Dijkstra算法中可以不用遍历到每个点,只要把所有房屋都访问到了就可以了,即使有些加油站访问不到或者超出了服务范围也不要紧。#include#include#include#include#include#includeusin
荡秋千de猪
·
2020-09-16 16:26
PAT(Advanced
Level)
1072
. Gas Station 解析
这个题的题目真的是好长好长,而且要理清的东西挺多的。不过后面的输出给了比较时候要用的数据的提示。首先,我们要保证加油站到居民楼越远越好,靠的是min{加油站到剧名楼的距离}的大小,取大的。然后min{}还相等,取avg{加油站到剧名楼的距离}的大小,取小的。然后avg{}还相等,取编号小的。这个题为了便于处理,我把编号连续化了,居民楼的编号排前面,加油站的接在后面。这样dijstra的算法能好写点
sheepyWYY
·
2020-09-16 16:48
PAT
1072
. Gas Station PAT Dijkstra算法
Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgiventhema
zhangchaosd
·
2020-09-16 16:03
pat甲级
1072
. Gas Station (30)
欢迎访问我的pat甲级题解目录哦https://blog.csdn.net/richenyunqi/article/details/84981078题目描述题意分析求出符合下列要求的加油站:到所有住宅区的距离都在服务范围之内在所有加油站到最近的住宅区的距离最远如果有多个加油站符合要求选择到所有住宅区平均距离最小的如果仍有多个加油站符合要求选择编号最小的算法设计首先,加油站按G1、G2……等形式编号
日沉云起
·
2020-09-16 16:02
pat甲级
PAT----A
1072
Gas Station (30point(s))
A
1072
GasStation(30point(s))题意给出加油站、房子之间的距离,最大服务距离,要求输出最优的加油站,如果没有符合条件(全部房子在服务范围内)的加油站则输出NoSolution最优就是这个加油站到房子的距离最小的最大
delicious__zen
·
2020-09-16 16:46
PAT
PAT甲级
1072
Gas Station (30 分)
1072
GasStation(30分)Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservice
番茄杀手Dexter
·
2020-09-16 16:07
PAT甲级
PAT
PAT 甲级
1072
Gas Station
题意:比较常规的一题,想复杂了,提醒自己一定要注意读题,求到每个村庄的最短距离的最远也即最大值,若不唯一,选择平均距离最小的那一条,仍然不唯一选择id最小的一个思路:每次用dijkstar算法求出从加油站到每个村庄的最小值,注意如果超过阈值或者是不相邻就抛弃该地点,而且加油站点中也要算在路径里面去最值,每次算出最小值之后要与之前的数据比较选择是否更新注意点:1.输出的时候用a和b临时接受输入数据,
tbywt
·
2020-09-16 16:05
dijkstar算法
图的相关问题
PAT之dijkstar算法
1072
Gas Station (dijkstra(无start与end 多次使用dijkstra))
1072
GasStation(30分)Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservice
月下独喝
·
2020-09-16 15:27
PAT甲级
1072
Gas Station (30 分)题解
\quad这个题要求每个加油站到所有居住地的最短距离,最长距离和平均距离。其中最长距离用于判断该加油站位置是否符合要求,最短距离和平均距离需要输出并保留一位小数。我用1到N表示居民居住地,N+1到N+M+1表示加油站,这样计算出某个加油站到其他地点的距离,保存在数组中,再进行处理。\quad在所有位置合法的加油站中,以最大化该加油站到居住地的最短距离为第一标准,最小化加油站到居住地的平均距离为第二
程勇uestc
·
2020-09-16 15:44
PAT甲级1072
Gas
Station
(30
分)题解
1072
Gas
Station
(30
分)
最短路
PAT
1072
这个题纯敲代码就花了30min,结果又斗争了半小时最后一个样例还是不对,看了别人的AC代码把+0.05四舍五入去了结果对了,所以PAT的题要是错了可以试试不写四舍五入。#includeusingnamespacestd;constintinf=1e9;vector>g;vectorvisit,d;intmain(){intn,m,k,ds;inth,r;setl;inti,j,t;ints1,s2
毛线岛民
·
2020-09-16 15:34
PAT
PAT甲级
1072
Gas Station (30 分)Dijkstra
1072
GasStation(30分)Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservice
love music.
·
2020-09-16 15:53
PAT
Dijkstra
PAT
PAT.A
1072
Gas Station
Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgiventhema
克拉拉123
·
2020-09-16 15:51
1072
Gas Station (30 point(s))
题解dijkstra的应用。#include#include#includeusingnamespacestd;constintMAXN=1e3+20;constintINF=0x3f3f3f3f;inte[MAXN][MAXN],dis[MAXN];boolvis[MAXN];intn,m,k,ds;inta,b,c;stringaa,bb;intmain(){fill(e[0],e[0]+MA
徐伯莱
·
2020-09-16 15:01
Pat甲级
Pat甲级
PAT A
1072
Gas Station(30 分)-------图最短路径---比较难点的题
总结:1.这道题用了dijstra算法,关键是开始对G1非数字的处理即Gi处理成i+n;我最后一个测试点开始没过就是因为用s.size()判断输入为数字还是G2,但是其实数据n+m是大于99的代码:#include#include#include#includeusingnamespacestd;intG[1100][1100];intn,m,k,ds;constintinf=99999999;i
不要绝望总会慢慢变强
·
2020-09-16 15:48
算法
pat甲级
数据结构学习
1072
. Gas Station (30)-PAT甲级真题(Dijkstra)
Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgiventhema
柳婼
·
2020-09-16 15:56
PAT
PAT
1072
C++版
PAT
1072
C++版1.题意给出一个图的顶点,以及边信息。每个顶点代表的含义是一个居民点。现在需要在这些居名点之间修建一个gasstation。
LawsonAbs
·
2020-09-16 15:24
#
PAT
PAT甲级
1072
. Gas Station (30)
Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgiventhema
liaotl10
·
2020-09-16 15:13
PAT甲级
Dijkstra_
1072
Gas Station (30 分)
1072
GasStation(30分)Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservice
阿_波_
·
2020-09-16 15:12
最短路
PAT练习
【PAT甲级】
1072
. Gas Station (30)
此题用Dijkstra计算;如果用Floyd最后一个测试用例会超时#include#include#include#include#include#include#defineINF1>n>>m>>k>>ds;N=m+n;intp1,p2,d;stringp1str,p2str;vectorv;for(inti=0;i>p1str>>p2str>>d;if(p1str[0]=='G')p1=n+a
lambsnow
·
2020-09-16 15:33
PAT
PAT
1072
Gas Station-Dijkstra算法
原题链接
1072
GasStation思路题目大意,存在n个居民点和m个加油站。
巧乐兹呀
·
2020-09-16 15:12
PAT
1072
Gas Station (30point(s)) - C语言 PAT 甲级
1072
GasStation(30point(s))Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinits
有三只土豆
·
2020-09-16 15:12
PAT
甲级
PAT
甲级
C语言
1072
. Gas Station (30)
Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgiventhema
hg_zhh0427
·
2020-09-16 15:34
PAT
最短路径算法
dijkstra算法
1072
. Gas Station (30) PAT+Dijkstra单源最短路径
题目:
1072
.GasStation(30)Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteeth
dailili1990
·
2020-09-16 14:05
PAT
1072
Gas Station (30 point(s))
1072
GasStation(30point(s))Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinits
coderwait
·
2020-09-16 14:21
PAT
(PAT
1072
) Gas Station (Dijkstra算法)
Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgiventhema
alex1997222
·
2020-09-16 14:56
ACM算法习题
PAT 甲级
1072
Gas Station
1072
GasStation(30point(s))Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinits
漫浸天空的雨色
·
2020-09-16 14:41
PAT甲级
PAT甲级/乙级机试经验
浙大PAT
1072
题
1072
. Gas Station
/*本题的题意开始没有理解,以为最优的第一条件就是平均值最小,但不是这样的。第一条件:所有候选点中到house最小值最大的那个候选点,第一个测试用例中G1的最小值为2,G2的最小值为1,G3的最小值为2,所以选取候选点G1和G3继续比较;424331345324G12.03.3第二条件:平均值最小,第一个测试用例中,G1的平均值小于G3,所以最优解为G3;第三条件:序号最小;*/#include#
Sup_Heaven
·
2020-09-16 14:47
浙大pat
1072
Gas Station (30分)
Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgiventhema
DayDream_x
·
2020-09-16 14:28
1072
Gas Station(30 分)
1072
GasStation(30分)Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservice
Cute_jinx
·
2020-09-16 14:27
pintia
PAT-A
1072
Gas Station 题目内容及题解
Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgiventhema
Bourbon_Whiskey_
·
2020-09-16 14:20
PAT甲级
【PAT】
1072
. Gas Station (30)【dijkstra算法】
题目描述Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgivent
幻世至上
·
2020-09-16 14:31
PAT练习
*PAT_甲级_
1072
Gas Station (30point(s)) (C++)【Dijkstra/字符串截取/与数字相互转换】
目录1,题目描述题目大意注意:2,思路数据结构算法3,AC代码4,解题过程第一搏第二搏1,题目描述SampleInput1:431151221421G141G232322G213423G324G13G2G11G3G22SampleOutput1:G12.03.3SampleInput2:212101G192G120SampleOutput2:NoSolution题目大意从给定的几个站点中,寻找最合
&再见萤火虫&
·
2020-09-16 14:46
PAT甲级
PAT
甲级
C++
1072
Dijkstra
字符串截取
1072
Gas Station (30分) PAT 甲级
1072
GasStation(30分)Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservice
生于忧患,死于安乐2017
·
2020-09-16 14:43
PTA
PAT
1072
Gas Station
题目链接:https://www.patest.cn/contests/pat-a-practise/
1072
思路:通读一遍下来,发现题目的意思就是在几个候选的建站点里选一个节点,让这个节点到各个居民点的距离满足
L.Jeremy
·
2020-09-16 14:31
PAT题解
A
1072
Gas Station 【图 - 最短路径】
题目链接题目分析给出M个加油站待选点和N个房屋,要求加油站距离最近的房子越远越好;(即最小距离中最大的那个)当有相同解时,选择平均距离更小的那一个,若还有多解,选择编号更小的那一个民房编号1~N(1000);气站编号G1~GM(10);解题思路对于所有候选站点,依次执行如下步骤:Dijkstra()算法查找最短路径,只需记录到每个结点的最短距离即可,不需要保存路径;每检查完一个待选点,判断:1、检
3stone_
·
2020-09-16 14:59
PAT
ACM-图
1072
Gas Station (30 分)--PAT甲级
1072
GasStation(30分)Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservice
NullObjectError
·
2020-09-16 13:35
PAT
Pat(A)
1072
. Gas Station (30)
原题目:原题链接:https://www.patest.cn/contests/pat-a-practise/10721072.GasStation(30)Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspos
萧易桥
·
2020-09-16 13:56
PAT甲级
PAT A
1072
Gas Station(30)
题意这个题读起来有点烦,是这样的,首先有N个居民房和M个加油站,每个加油站都对应着一个最小距离和平均距离,加油站的最小距离是指从他到其他所有居民房的最短路径的最小值(从N条最短路径里面选),现在让你选择一个加油站,首先他到所有居民房的最短路径均不能大于服务范围(每个加油站都一样),其次他的最小距离在所有加油站的最小距离中最大(从M个加油站中选),若不唯一,选择平均距离最小的,若再不唯一,选择编号最
Crossing over
·
2020-09-16 13:44
图论
图论
-
最短路
PAT
甲级
PAT (Advanced Level) Practice
1072
Gas Station(30分)【最短路径】
Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgiventhema
海盐味的可爱多
·
2020-09-16 13:23
PAT
1072
. Gas Station (30)
题目链接:http://www.patest.cn/contests/pat-a-practise/
1072
题目:Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustgu
陈小旭
·
2020-09-16 13:50
PAT
PAT
最短路径
【未完成】【笨方法学PAT】
1072
Gas Station (30 分)
一、题目Agasstationhastobebuiltatsuchalocationthattheminimumdistancebetweenthestationandanyoftheresidentialhousingisasfarawayaspossible.Howeveritmustguaranteethatallthehousesareinitsservicerange.Nowgivent
技术_李艳宾
·
2020-09-16 13:23
PAT
C
PAT甲级
PAT乙级题解(
1072
. 开学寄语)
1072
.开学寄语(20)时间限制400ms内存限制65536kB代码长度限制8000B判题程序Standard作者CHEN,Yue下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其
HytonightYX
·
2020-09-15 21:16
PAT乙级
zookeeper导致的8080端口被占用
windows和linunx解决方案同下如图所示:8080和2181的pid都为
1072
,所以本次端口被占用的原因已经定位zk的配置文件添加admin.serverPort=8888我的zk配置文件路径为
CSDN_苦瓜不苦
·
2020-09-15 18:55
java
zookeeper
linux
NEUQACM OJ:
1072
--谭浩强C语言(第三版)习题9.3
NEUQACMOJ:
1072
–谭浩强C语言(第三版)习题9.3题目如下一道强行要求用宏的题目。。。用就用吧,谁怕谁?!
NEUQacmer
·
2020-09-12 12:18
MySQL时间点数据恢复测试步骤--基于Position
MySQL时间点数据恢复测试步骤(基于Position):1、查看当前的二进制日志的名称及位置mysql>showmasterstatus;|master-bin.000001|
1072
、修改数据库的信息并记录相应的修改内容以便于恢复后比对
weixin_34396103
·
2020-09-11 17:56
HDU
1072
NYOJ 483 Nightmare -- BFS+允许回头
/*有两种做法:一个不考虑走了回头路,因为数据是在是小,几乎不浪费时间另一个是用贪心策略,先假设所有点剩余时间为0,只要该点剩余时间小于上一点剩余时间-1则修改remain值为remain-1再入队,否则不入队*/#include#include#include#include#includeusingnamespacestd;#defineCLR(c,v)(memset(c,v,sizeof(c
x314542916
·
2020-08-26 15:57
【搜索】
【搜索】BFS
PAT甲组
1072
.Gas Station思路与注意点--补充《算法笔记》
A
1072
题目链接个人思路对每个加油站做Dijkstra,最后对比每个加油站找到最短距离最大的值,并计算最短距离的平均值也遇到了几个细节问题,找了好长时间数组大小:要考虑所有顶点数量和加油站数量,数组大小要开到
九筒-
·
2020-08-26 15:52
PAT
算法
数据结构
图论
c++
nyoj
1072
我想回家
一道相当题目描述相当扯的题。这道题目的描述最后说的是求出到达最后一个点的最短距离,所以输入数据最后输入的城堡的坐标是没用的。就是先求出两点之间的距离,若不大于村落间距离,并且不大于最后的距离限制l,则在两点间建边。最后任意方法求出最短路即可。#include#include#include#include#include#include#include#includeusingnamespaces
染指的流年
·
2020-08-26 14:13
图论_最短路
我愿做《时间的朋友》
图片发自App作为得到的老用户,进入得到已
1072
天,连续跟了四年的《时间的朋友》跨年演讲,自觉成长了许多,对这个世界,对人性有了更清晰的自我认知,但也不会像网上某些文章说的,会因此鄙视其他不是得到系的群体
囧囧雕塑家
·
2020-08-26 13:19
NYOJ
1072
我想回家_最短路径
原题地址:点击打开链接此题略坑。。。#include#include#include#defineMAX1(v1.r+v2.r)||l>d)//如果大于两圆的半径之和或者大于最长行走距离则排除returnfalse;returntrue;}doubledjks(ints){memset(used,0,sizeof(used));inti,j,u;doublemin;for(i=1;idis[u]+
给糖吃的小骗子
·
2020-08-26 11:45
图论
上一页
1
2
3
4
5
6
7
8
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他