Link: here
Analysis: a simple search... You can directly perform a brute-force search .. I don't know why the summer wind classifies him into level1 ....
Code:
# Include <iostream> # include <cstdio> using namespace STD; int ansnum; int neigh [22] [3]; bool vis [22]; int State [22]; int m; void DFS (int x, int num) {int I, j; If (num = 20) {bool flag = false; for (I = 0; I <3; I ++) if (Neigh [x] [I] = m) Flag = true; If (FLAG) {ansnum ++; printf ("% d: ", ansnum); For (j = 0; j <20; j ++) printf (" % d ", State [J]); printf ("% d \ n", m) ;}return ;}for (I = 0; I <3; I ++) {If (! Vis [Neigh [x] [I]) {State [num] = neigh [x] [I]; vis [Neigh [x] [I] = true; DFS (Neigh [x] [I], num + 1); vis [Neigh [x] [I] = false ;}} int main () {int I; for (I = 1; I <= 20; I ++) {scanf ("% d", & neigh [I] [0], & neigh [I] [1], & neigh [I] [2]);} while (scanf ("% d", & M), m) {ansnum = 0; memset (VIS, false, sizeof (VIS); vis [m] = true; State [0] = m; DFS (M, 1) ;}return 0 ;}