没有合适的资源?快使用搜索试试~ 我知道了~
首页2018年ACM国际大学生程序设计竞赛真题
资源详情
资源评论
资源推荐
Problem A
Catch the Plane
Time limit: 10 seconds
Your plane to the ICPC Finals departs in a short time, and the only way to get to the airport is by bus.
Unfortunately, some of the bus drivers are considering going on strike, so you do not know whether
you can get to the airport on time. Your goal is to plan your journey in such a way as to maximize the
probability of catching your plane.
You have a detailed map of the city, which includes all the bus stations. You are at station 0 and the
airport is at station 1. You also have a complete schedule of when each bus leaves its start station and
arrives at its destination station. Additionally, for each bus you know the probability that it is actually
going to run as scheduled, as opposed to its driver going on strike and taking the bus out of service.
Assume all these events are independent. That is, the probability of a given bus running as planned does
not change if you know whether any of the other buses run as planned.
If you arrive before the departure time of a bus, you can transfer to that bus. But if you arrive exactly
at the departure time, you will not have enough time to get on the bus. You cannot verify ahead of time
whether a given bus will run as planned – you will find out only when you try to get on the bus. So if
two or more buses leave a station at the same time, you can try to get on only one of them.
20%
Bus Schedule
Start
Station
Destination
Station
Departure
Time
Arrival
Time
0
0
2
2
0
3
3
0
1
2
1
1
3
1
0
1
0
100
500
501
200
500
550
700
900
500
700
701
400
800
650
900
10%
50%
10%
90%
10%
Figure A.1: Bus schedule corresponding to Sample Input 1.
Consider the bus schedule shown in Figure A.1. It lists the start and destination stations of several bus
routes along with the departure and arrival times. You have written next to some of these the probability
that that route will run. Bus routes with no probability written next to them have a 100% chance of
running. You can try catching the first listed bus. If it runs, it will take you straight to the airport, and
you can stop worrying. If it does not, things get more tricky. You could get on the second listed bus to
station 2. It is certain to leave, but you would be too late to catch the third listed bus which otherwise
would have delivered you to the airport on time. The fourth listed bus – which you can catch – has only
a 0.1 probability of actually running. That is a bad bet, so it is better to stay at station 0 and wait for
the fifth listed bus. If you catch it, you can try to get onto the sixth listed bus to the airport; if that does
not run, you still have the chance of returning to station 0 and catching the last listed bus straight to the
airport.
ACM-ICPC World Finals 2018 Problem A: Catch the Plane 1
Input
The first line of input contains two integers m (1 ≤ m ≤ 10
6
) and n (2 ≤ n ≤ 10
6
), denoting the number
of buses and the number of stations in the city. The next line contains one integer k (1 ≤ k ≤ 10
18
),
denoting the time by which you must arrive at the airport.
Each of the next m lines describes one bus. Each line contains integers a and b (0 ≤ a, b < n, a 6= b),
denoting the start and destination stations for the bus. Next are integers s and t (0 ≤ s < t ≤ k),
giving the departure time from station a and the arrival time at station b. The last value on the line is p
(0 ≤ p ≤ 1, with at most 10 digits after the decimal point), which denotes the probability that the bus
will run as planned.
Output
Display the probability that you will catch your plane, assuming you follow an optimal course of action.
Your answer must be correct to within an absolute error of 10
−6
.
Sample Input 1 Sample Output 1
8 4
1000
0 1 0 900 0.2
0 2 100 500 1.0
2 1 500 700 1.0
2 1 501 701 0.1
0 3 200 400 0.5
3 1 500 800 0.1
3 0 550 650 0.9
0 1 700 900 0.1
0.3124
Sample Input 2 Sample Output 2
4 2
2
0 1 0 1 0.5
0 1 0 1 0.5
0 1 1 2 0.4
0 1 1 2 0.2
0.7
ACM-ICPC World Finals 2018 Problem A: Catch the Plane 2
Problem B
Comma Spr inkler
Time limit: 8 seconds
Photo by Tanya Hart. Yarn
pattern by Morgen Dämmerung.
As practice will tell you, the English rules for comma placement are complex, frus-
trating, and often ambiguous. Many people, even the English, will, in practice,
ignore them, and, apply custom rules, or, no rules, at all.
Doctor Comma Sprinkler solved this issue by developing a set of rules that sprinkles
commas in a sentence with no ambiguity and little simplicity. In this problem you
will help Dr. Sprinkler by producing an algorithm to automatically apply her rules.
Dr. Sprinkler’s rules for adding commas to an existing piece of text are as follows:
1. If a word anywhere in the text is preceded by a comma, find all occurrences of that word in the text,
and put a comma before each of those occurrences, except in the case where such an occurrence
is the first word of a sentence or already preceded by a comma.
2. If a word anywhere in the text is succeeded by a comma, find all occurrences of that word in the
text, and put a comma after each of those occurrences, except in the case where such an occurrence
is the last word of a sentence or already succeeded by a comma.
3. Apply rules 1 and 2 repeatedly until no new commas can be added using either of them.
As an example, consider the text
please sit spot. sit spot, sit. spot here now here.
Because there is a comma after spot in the second sentence, a comma should be added after spot in
the third sentence as well (but not the first sentence, since it is the last word of that sentence). Also,
because there is a comma before the word sit in the second sentence, one should be added before that
word in the first sentence (but no comma is added before the word sit beginning the second sentence
because it is the first word of that sentence). Finally, notice that once a comma is added after spot
in the third sentence, there exists a comma before the first occurrence of the word here. Therefore, a
comma is also added before the other occurrence of the word here. There are no more commas to be
added so the final result is
please, sit spot. sit spot, sit. spot, here now, here.
Input
The input contains one line of text, containing at least 2 characters and at most 1 000 000 characters.
Each character is either a lowercase letter, a comma, a period, or a space. We define a word to be a
maximal sequence of letters within the text. The text adheres to the following constraints:
• The text begins with a word.
• Between every two words in the text, there is either a single space, a comma followed by a space,
or a period followed by a space (denoting the end of a sentence and the beginning of a new one).
• The last word of the text is followed by a period with no trailing space.
ACM-ICPC World Finals 2018 Problem B: Comma Sprinkler 3
Output
Display the result after applying Dr. Sprinkler’s algorithm to the original text.
Sample Input 1
please sit spot. sit spot, sit. spot here now here.
Sample Output 1
please, sit spot. sit spot, sit. spot, here now, here.
Sample Input 2
one, two. one tree. four tree. four four. five four. six five.
Sample Output 2
one, two. one, tree. four, tree. four, four. five, four. six five.
ACM-ICPC World Finals 2018 Problem B: Comma Sprinkler 4
Problem C
Conquer The World
Time limit: 8 seconds
Bwahahahahaha!!! Your nemesis, the dashingly handsome spy Waco Powers, has at last fallen to your
secret volcano base’s deathtraps (or so you assume, being a little too busy to witness it firsthand). At
long last, you are all set to CONQUER THE WORLD!
Nothing will stand in your way! Well, nothing except a minor problem of logistics. Your evil armies
have announced that they will not continue carving their relentless path of destruction across the puny
nations of the world without being paid. And unfortunately you are running low on cash – a volcano
lair has many wonderful qualities, but “reasonably affordable” is not one of them. You have had to pull
funds from the travel budget to pay your ungrateful underlings. Now you are not sure how you will
actually get your armies into position to CONQUER THE WORLD.
You have a map of the nations of the world and all your available transport routes between them. Each
route connects two nations and has a fixed cost per army that uses it. The routes are laid out such that
there is exactly one way to travel between any two nations. You know the current position of each of
your armies and how many you will need to place permanently in each nation in order to subjugate it.
How can you move the armies into place as cheaply as possible so you can CONQUER THE WORLD?
Input
The first line of input contains an integer n (1 ≤ n ≤ 250 000), the number of nations. This is followed
by n − 1 lines, each containing three integers u, v, and c (1 ≤ u, v ≤ n, 1 ≤ c ≤ 10
6
), indicating that
there is a bidirectional route connecting nations u and v, which costs c per army to use.
Finally, another n lines follow, the i
th
of which contains two non-negative integers x
i
and y
i
, indicating
that there are currently x
i
armies in nation i, and you need at least y
i
armies to end up in that nation in
the final configuration. The total number of armies (the sum of the x
i
values) is at least the sum of the
y
i
values, and no more than 10
6
.
Output
Display the minimum cost to move your armies such that there are at least y
i
armies in nation i for all i.
Sample Input 1 Sample Output 1
3
1 2 5
3 1 5
2 1
5 0
1 3
15
ACM-ICPC World Finals 2018 Problem C: Conquer The World 5
剩余21页未读,继续阅读
nibolyoung
- 粉丝: 12
- 资源: 24
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0