当前位置:网站首页>PAT. A1018 Public Bike Management
PAT. A1018 Public Bike Management
2022-07-18 00:48:00 【51CTO】


The question
There are some public bicycle stations in the city , The maximum capacity of bicycles at each station is an even number Cmax, And if the number of bicycles in a station happens to be Cmax/2, Then the station is called “ Perfect state ”. If the capacity of a station is full or empty , Then the control center (PBMC) Will carry or collect a certain number of bicycles from the road to the station , So that the problem station and all stations along the way can reach “ Perfect state ”. Now give Cmax、 Number of stations N ( Excluding Control Center PBMC)、 Question station number Sp、 Undirected edge number M And edge right , Ask for a way from PBMC ( Write it down as 0 Number ) Arrive at the problem station Sp Shortest path , The output needs to be from PBMC Number of bicycles carried 、 Shortest path 、 The number of bicycles to be brought back after arriving at the station in question . If there are multiple shortest paths , Then choose from PBMC The one who carries the least number of bicycles : If there are still multiple , Then choose the one with the least number of bicycles brought back from the station in question . Be careful : The adjustment process of all stations along the way must be completed in the process of going to the problem station , No adjustment when bringing back .
Examples ( Replicable )
Be careful
- The idea of solving this problem is Djikstra+DFS. Specific for : First use Dijkstra Find the shortest path , In the process of finding , Record the precursor node of each node of each path . Use DFS Start from the problem site , Use the precursor node just recorded to return to PBMC, Write down the path , Again from PBMC Calculate the number of bicycles you need to take when you leave need And the number of bicycles that need to be retrieved remain, And minneed and minremain Compare , Update shortest path .
边栏推荐
- 科技公司纷纷反对 英国网络安全法案搁置
- [source code] what is the difference between ArrayList and vector, and the difference of expansion multiple
- C JSON is converted to entity class and generates code
- 1300_ Analysis of priority related knowledge points in FreeRTOS
- 【数学建模暑期培训】Matlab的数据处理
- 拓扑排序原理
- Modern data stack: develop data efficiently and assist enterprise decision-making
- Typescript 14 starting from 0: built in tool type
- Q3 QMainWindow 菜单栏和工具栏
- mysql进阶(三)游标简易知识点汇总
猜你喜欢

Chat software project development 1
![[mathematical modeling summer training] CUMCM calendar year problem classification 2000-2021 digital modeling national competition problem and solution model](/img/42/1a9eb3ceb63e0191e8d19d89db4619.png)
[mathematical modeling summer training] CUMCM calendar year problem classification 2000-2021 digital modeling national competition problem and solution model

北航学长的NLP赛事教程!

Why is there no Productism in Wei Lai?
![[interview question] what is the difference between poll() and remove() in the queue](/img/5c/2757c1be47d22dbd61510fb2f6e292.png)
[interview question] what is the difference between poll() and remove() in the queue
![[JMeter] win10 download and install JMeter 5.5](/img/92/9654d32eada08f33db43f7c45e8be1.png)
[JMeter] win10 download and install JMeter 5.5

从0开始的 TypeScriptの十四:内置工具类型

MacM1芯片,centos8虚拟机安装mysql8,服务起来了,登录报错

Q3 QmainWindow 状态栏 铆接部件 核心部件

MFC implementation class serialization
随机推荐
CF1265E Beautiful Mirrors (概率dp)
【LeetCode】Day100-颜色分类
[mathematical modeling summer training] matlab program design
I want to open a futures account. Where is it convenient and safe to open an account?
GCC rust is approved to be included in the mainline code base, or will meet you in GCC 13
001.Hello World
QPS和TPS的区别
h5 调起小程序
[Arduino six channel ADC sampling of Renesas ra6m4 development board]
[source code] implementation principle of HashSet
[JMeter] win10 download and install JMeter 5.5
This SQL will report an error when it is executed in pg. Oracle is OK
Cf1265e beautiful mirrors (probability DP)
[mathematical modeling summer training] matlab for finding symbolic solutions and numerical solutions of algebraic equations
Typescript 14 starting from 0: built in tool type
Tracknet usage record: environment configuration
spark调优(六):大家好才是真的好——广播变量
MFC控件学习:图片(bmp/png)
C JSON is converted to entity class and generates code
Record the first business trip of new programmers