#P2151. [SDOI2009] HH 去散步

    ID: 1129 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>递推2009各省省选山东矩阵乘法构造

[SDOI2009] HH 去散步

Description

HH has an unchanging habit: he likes to walk one hundred steps after meals. By “one hundred steps,” he means taking a walk, that is, covering a certain distance within a certain time. However, HH also likes variety, so he will not immediately walk back along the road he just took. Since he likes variety, the path he takes each day is not exactly the same. He wants to know how many different ways he can take such a walk.

You are given the school’s map (assume every road has the same length, which is 11). Find the number of valid paths of length tt from a given location AA to a given location BB.

Input Format

The first line contains five integers N,M,t,A,BN, M, t, A, B. Here NN is the number of intersections in the school, MM is the number of roads, tt is the distance HH wants to walk, AA is the starting point, and BB is the destination.

The next MM lines each contain a pair Ai,BiA_i, B_i, meaning there is a road from intersection AiA_i to intersection BiB_i. It is guaranteed that AiBiA_i \neq B_i, but there may be multiple roads connecting the same pair of intersections. Intersections are numbered from 00 to N1N-1. All data on the same line are separated by a single space, and there are no extra spaces at the beginning or end of lines. There are no extra blank lines.

Output Format

Output one line: the answer modulo 4598945989.

4 5 3 0 0
0 1
0 2
0 3
2 1
3 2
4

Hint

Constraints and Conventions

For 30%30\% of the testdata, N4N \le 4, M10M \le 10, t10t \le 10.

For 100%100\% of the testdata, N50N \le 50, M60M \le 60, t230t \le 2^{30}, 0A,B0 \le A, B.

Translated by ChatGPT 5