I. Ship Traffic
의견: 0
Ferries crossing the Strait of Gibraltar from Morocco to Spain must carefully navigate to avoid the heavy ship traffic along the strait. Write a program to help ferry captains find the largest gaps in strait traffic for a safe crossing. Your program will use a simple model as follows. The strait has several parallel shipping lanes in ea\(st- we\)st direction. Ships run with the same constant speed either eastbound or westbound. All ships in the same lane run in the same direction. Satellite data provides the positions of the ships in each lane. The ships may have different lengths. Ships do not change lanes and do not change speed for the crossing ferry. The ferry waits for an appropriate time when there is an adequate gap in the ship traffic. It then crosses the strait heading northbound along a nor\(th-so\)uth line at a constant speed. From the moment a ferry enters a lane until the moment it leaves the lane, no ship in that lane may touch the crossing line. Ferries are so small you can neglect their size. Figure I.1 illustrates the lanes and ships for Sample Input 1. Your task is to find the largest time interval within which the ferry can safely cross the strait. Ferry S N W E Figure I.1: Sample Input 1.
The first line of input contains six integers: the number of lanes \(n\) (\(1 \le n \le 10^{5}\)), the width \(w\) of each lane (\(1 \le w \le 1\,000\)), the speed \(u\) of ships and the speed \(v\) of the ferry (\(1 \le u\), \(v \le 100\)), the ferry’s earliest start time \(t_{1}\) and the ferry’s latest start time \(t_{2}\) (\(0 \le t_{1} < t_{2} \le 10^{6}\)). All lengths are given in meters, all speeds are given in mete\(rs/se\)cond, and all times are given in seconds. Each of the next \(n\) lines contains the data for one lane. Each line starts with either E or W, where E indicates that ships in this lane are eastbound and W indicates that ships in this lane are westbound. Next in the line is an integer \(m_{i}\), the number of ships in this lane (\(0 \le m_{i} \le 10^{5}\) for each \(1 \le i \le n\)). It is followed by \(mi\) pairs of integers \(lij\) and \(pij\) (\(1 \le lij \le 1\,000\) a\(nd - 10^{6} \le pij \le 10^{6}\)). The length of ship \(j\) in lane \(i\) is \(lij\), and \(pij\) is the position at time 0 of its forward end, that is, its front in the direction it moves. Ship positions within each lane are relative to the ferry’s crossing line. Negative positions are west of the crossing line and positive positions are east of it. Ships do not overlap or touch, and are sorted in increasing order of their positions. Lanes are ordered by increasing distance from the ferry’s starting point, which is just south of the first lane. There is no space between lanes. The total number of ships is at least 1 and at most \(10^{5}\).
Display the maximal value \(d\) for which there is a time \(s\) such that the ferry can start a crossing at any time \(t\) with \(s \le t \le s + d\). Additionally the crossing must not start before time \(t_{1}\) and must start no later than time \(t\)2. The output must have an absolute or relative error of at most \(10^{−}^{3}\). You may assume that there is a time interval with \(d > 0\).1 seconds for the ferry to cross.
3 100 5 10 0 100
E 2 100 -300 50 -100
W 3 10 60 50 200 200 400
E 1 100 -300
6.00000000
1 100 5 10 0 200
W 4 100 100 100 300 100 700 100 900
50.00000000
평가 및 의견
I. Ship Traffic
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
I. Ship Traffic