RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
R03667

Traffic Lights

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

TRAFFIC LIGHTS
PROBLEM
In the city of Dingilville the traffic is arranged in an unusual way. There are junctions and roads connecting the
junctions. There is at most one road between any two different junctions. There is no road connecting a junction to
itself. Travel time for a road is the same for both directions. At every junction there is a single traffic light that is either
blue or purple at any moment. The color of each light alternates periodically: blue for certain duration and then purple
for another duration. Traffic is permitted to travel down the road between any two junctions, if and only if the lights
at both junctions are the same color at the moment of departing from one junction for the other. If a vehicle arrives at
a junction just at the moment the lights switch it must consider the new colors of lights. Vehicles are allowed to wait at
the junctions. You are given the city map which shows

the travel times for all roads (integers),

the durations of the two colors at each junction (integers)

and the initial color of the light and the remaining time (integer) for this color to change at each junction.
Your task is to find a path which takes the minimum time from a given source junction to a given destination
junction for a vehicle when the traffic starts. In case more than one such path exists you are required to report
only one of them.

ASSUMPTIONS

2 <= N <=300 where N is the number of junctions. The junctions are identified by integers 1 through N. These
numbers are called id-numbers.

1 <=M <=14,000 where M is the number of roads.

1 <= lij <= 100 where lij is the time required to move from junction i to j using the road that connects i and j.

1 <= tic <= 100 where tic is the duration of the color c for the light at the junction i. The index c is
either B for blue or P for purple.

1 <= ric <= tic where ric is the remaining time for the initial color c at junction i.

EXAMPLE

EVALUATION
Your program will be allowed to run 2 seconds.
No partial credit can be obtained for a test case.

제약
입력 형식

The input is a text file named lights.inp.

The first line contains two numbers: The id-number of the source junction and the id-number of the destination
junction.

The second line contains two numbers: N, M.

The following N lines contain information on N junctions. The (i+2)’th line of the input file holds information about
the junction i : Ci, ric, tiB, tiP where Ci is either ‘B’ or ‘P’, indicating the initial color of the light at the junction i.

Finally, the next M lines contain information on M roads. Each line is of the form: i, j, lij where i and j are the id-
numbers of the junctions which are connected by this road .

출력 형식

The output must be a text file named lights.out.
If a path exists:

The first line will contain the time taken by a minimum-time path from the source junction to the destination
junction.

Second line will contain the list of junctions that construct the minimum-time path you have found. You have to
write the junctions to the output file in the order of travelling. Therefore the first integer in this line must be the id-
number of the source junction and the last one the id-number of the destination junction.
If a path does not exist:

A single line containing only the integer 0.

문제 정보

생성자가 기록되지 않았습니다.

출처 IOI 1999

평가 및 의견

Traffic Lights

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Traffic Lights

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8