#P4159. [SCOI2009] 迷路

    ID: 3092 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2009四川各省省选枚举,暴力矩阵乘法

[SCOI2009] 迷路

Description

The directed graph has nn nodes, numbered from 11 to nn. windy starts from node 11 and must arrive at node nn exactly at time tt.

Given the directed graph, can you tell windy how many different paths there are?

The answer is taken modulo 20092009.

Note: windy cannot wait at any node, and the time to traverse any directed edge is exactly the specified time.

Input Format

The first line contains two integers, nn and tt.

Lines 22 to n+1n+1 each contain a string of length nn. In line (i+1)(i+1), the jj-th character ci,jc_{i,j} is a digit. If it is 00, there is no edge from node ii to node jj; otherwise, the length of the edge from node ii to node jj is ci,jc_{i,j}.

Output Format

Output a single integer: the answer modulo 20092009.

2 2
11
00
1


5 30
12045
07105
47805
12024
12345

852

Hint

  • Explanation for Sample Input/Output 1
    The path is 1121 \to 1 \to 2.

  • Constraints

    • For 30%30\% of the testdata, n5n \leq 5, t30t \leq 30.
    • For 100%100\% of the testdata, 2n102 \leq n \leq 10, 1t1091 \leq t \leq 10^9.

Translated by ChatGPT 5