Logo
(追記) (追記ここまで)

18402번 - RUN 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB30213812050.209%

문제

An evil gang has decided to free prisoners from their prison. The prison is designed as a spiral and has a number of solitary cells. Prisoners are given a certain time to find their way out of prison. They shall be released if they can find their way out within the given time. Otherwise, the prison doors will be closed again. The prison has N cells that are connected together in a spiral form. Each cell has paths with a number of other cells. The prison has E exit doors. While escaping, each cell can contain as many people as possible.

With the assumption that prisoners know every path, write a program that predicts the number of prisoners that can and can't escape from the prison.

입력

The first three input lines contain

  • N, the number of cells in the prison. Cells are numbered 1, 2, ..., N. (N <= 100)
  • E, the number of the exit cell. (0 < E < 100)
  • T, starting value for the count-down timer (in some arbitrary time unit). (0 < T < 1000)

The fourth line contains M the number of connections in the prison. Each next M lines, specify a connection (one-way connection) between cells with three integer numbers: two cell numbers A and B (in the range 1, ..., N) and the number of time units it takes to travel from A to B.

Notice that each connection is one-way, i.e., the prisoner can't travel from B to A unless there is another line specifying that passage. Also, the time required to travel in each direction might be different.

출력

Output a single line with the number of prisoners that reached the exit cell.

제한

예제 입력 1

4
2
1
8
1 2 1
1 3 1
2 1 1
2 4 1
3 1 1
3 4 1
4 2 1
4 3 1

예제 출력 1

3

힌트

출처

ICPC > Regionals > Asia West Continent > Afghanistan > ICPC Asia Kabul Regional Contest 2019 11번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /