public void BFS() { boolean[] V = new boolean[1 << (N * M)]; List<TOE> lst = new LinkedList<>(); lst.add(this); V[this.toInt()] = true; TOE t = null; while (lst.size() > 0) { t = lst.remove(0); // System.out.println(t); if (t.solved()) break; for (TOE ti : t.next()) if (!V[ti.toInt()]) { ti.parent = t; lst.add(ti); V[ti.toInt()] = true; } } t.print(0); }
public void print(int j) { if (parent != null) { parent.print(j + 1); System.out.println((my + 1) + " " + (mx + 1)); } else System.out.println(j); }