-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go2
40 lines (35 loc) · 604 Bytes
/
main.go2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
// vim:set ft=go:
// snip ------------------------------------------------------------------------
const (
// big prime
P1b7 = 1000000007
P1b9 = 1000000009
P0b3 = 998244353
)
var DEBUG bool
var RANDOM_SEED int64
func Main() {
N := readi()
K := readi()
T := make([][]int, N)
for i := range T {
_, T[i] = readInts(N)
}
M := N - 1
a := make([]int, M)
Iota(a, 1)
var ans int
for ok := true; ok; ok = NextPermutation(a) {
var k int
k += T[0][a[0]]
k += T[a[M-1]][0]
for i := 0; i < M-1; i++ {
k += T[a[i]][a[i+1]]
}
if k == K {
ans++
}
}
println(ans)
}