MICEMAZE - Mice and Maze

题意翻译

### 题目描述 给定一个 $n$ 个点, $m$ 条边的图,问有多少个点到 $e$ 的最短路长度小于等于 $t$ (包括 $e$ 在内)。 ### 输入格式 前 $4$ 行,为 $n ,e ,t ,m$ 。含义如题面所述。 第 $5 \thicksim m + 4$ 行,每行输入三个数描述一条边,依次表示边的起点,边的终点和边权。 ### 输出格式 一行,一个正整数表示答案。 ### 说明/提示 $n \le 100$ , 输入数据均在 $int$ 范围内。

题目描述

MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']], skipTags: ["script","noscript","style","textarea","code"] } }); A set of laboratory mice is being trained to escape a maze. The maze is made up of cells, and each cell is connected to some other cells. However, there are obstacles in the passage between cells and therefore there is a time penalty to overcome the passage Also, some passages allow mice to go one-way, but not the other way round. Suppose that all mice are now trained and, when placed in an arbitrary cell in the maze, take a path that leads them to the exit cell in minimum time. We are going to conduct the following experiment: a mouse is placed in each cell of the maze and a count-down timer is started. When the timer stops we count the number of mice out of the maze. Problem \------- Write a program that, given a description of the maze and the time limit, predicts the number of mice that will exit the maze. Assume that there are no bottlenecks is the maze, i.e. that all cells have room for an arbitrary number of mice.

输入输出格式

输入格式


The maze cells are numbered $1, 2, \\ldots, N$, where $N$ is the total number of cells. You can assume that $N \\le 100$. The first three input lines contain $N$, the number of cells in the maze, $E$, the number of the exit cell, and the starting value $T$ for the count-down timer (in some arbitrary time unit). The fourth line contains the number $M$ of connections in the maze, and is followed by $M$ lines, each specifying a connection with three integer numbers: two cell numbers $a$ and $b$ (in the range $1, \\ldots, 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 mice can't travel from $b$ to $a$ unless there is another line specifying that passage. Notice also that the time required to travel in each direction might be different.

输出格式


The output consists of a single line with the number of mice that reached the exit cell $E$ in at most $T$ time units.

输入输出样例

输入样例 #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