
1 pigf 339 天前 |
2 lxdlam 339 天前 在 GF(2) 域上解线性方程组。 |
3 zihuyishi 339 天前 我写了一个深搜,算的 13 步能跑完,不知道对不对 ```golang package main import "fmt" const N = 5 type Status [N][N]bool func (s Status) Click(x, y int) Status { s[x][y] = !s[x][y] if x > 0 { s[x-1][y] = !s[x-1][y] } if x < N-1 { s[x+1][y] = !s[x+1][y] } if y > 0 { s[x][y-1] = !s[x][y-1] } if y < N-1 { s[x][y+1] = !s[x][y+1] } return s } func (s Status) IsAllOn() bool { for i := 0; i < N; i++ { for j := 0; j < N; j++ { if !s[i][j] { return false } } } return true } func (s Status) Hash() int64 { h := int64(0) for i := 0; i < N; i++ { for j := 0; j < N; j++ { h = h * 2 if s[i][j] { h += 1 } } } return h } type Node struct { Status Status Step int } func search(s Status) (int, bool) { searched := make(map[int64]bool) queue := make([]Node, 0) queue = append(queue, Node{Status: s, Step: 0}) searched[s.Hash()] = true for len(queue) > 0 { cur := queue[0] queue = queue[1:] if cur.Status.IsAllOn() { return cur.Step, true } for i := 0; i < N; i++ { for j := 0; j < N; j++ { next := cur.Status.Click(i, j) if next.IsAllOn() { return cur.Step + 1, true } if !searched[next.Hash()] { queue = append(queue, Node{Status: next, Step: cur.Step + 1}) searched[next.Hash()] = true } } } } return 0, false } func main() { s := Status{ {false, true, false, false, false}, {true, true, true, false, false}, {false, true, false, true, false}, {false, false, true, true, true}, {false, false, false, true, false}, } step, ok := search(s) fmt.Println(step, ok) } ``` |
8 Kaciras 339 天前 小学的时候玩过好多 Flash 版的,一个经验是先搞到对称,后续也对称操作。 |
9 mozhizhu 339 天前 我以为是:“小爱同学,关掉所有的灯” |
13 Yanlongli 338 天前 最好能保持当前关卡,每次重新开始都要从头再来 |
15 zwzwzwzwzxt 338 天前 |
16 lthero 338 天前 @zwzwzwzwzxt #15 无解 |
17 lthero 338 天前 第 28 关似乎无解? |
18 lthero 338 天前 @zwzwzwzwzxt #15 尝试在 GF(2)域上解线性方程组,其它关都有最优解,第 28 关无解; |
20 zwzwzwzwzxt 337 天前 @lthero 我就说程序跑出来咋还剩一个 |