AtCoder Beginner Contest 183
C
Travel
AtCoder
⌀ 329
原题
← BD →
翻译中…

Problem Statement

翻译中…

There are $N$ cities. The time it takes to travel from City $i$ to City $j$ is $T_{i, j}$.

翻译中…

Among those paths that start at City $1$, visit all other cities exactly once, and then go back to City $1$, how many paths take the total time of exactly $K$ to travel along?

翻译中…

Constraints

翻译中…
  • $2\leq N \leq 8$
  • If $i\neq j$, $1\leq T_{i,j} \leq 10^8$.
  • $T_{i,i}=0$
  • $T_{i,j}=T_{j,i}$
  • $1\leq K \leq 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K
T_{1,1} \ldots T_{1,N}
\vdots
T_{N,1} \ldots T_{N,N}

翻译中…

Output

翻译中…

Print the answer as an integer.

翻译中…

样例

Input #1
4 330
0 1 10 100
1 0 20 200
10 20 0 300
100 200 300 0
Output #1
2
There are six paths that start at City $1$, visit all other cities exactly once, and then go back to City $1$: - $1\to 2\to 3\to 4\to 1$ - $1\to 2\to 4\to 3\to 1$ - $1\to 3\to 2\to 4\to 1$ - $1\to 3\to 4\to 2\to 1$ - $1\to 4\to 2\to 3\to 1$ - $1\to 4\to 3\to 2\to 1$ The times it takes to travel along these paths are $421$, $511$, $330$, $511$, $330$, and $421$, respectively, among which two are exactly $330$.
Input #2
5 5
0 1 1 1 1
1 0 1 1 1
1 1 0 1 1
1 1 1 0 1
1 1 1 1 0
Output #2
24
In whatever order we visit the cities, it will take the total time of $5$ to travel.
题目信息
题号
abc183_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。