The practice is similar to 1753.
The Code is as follows:
# Include <cstdlib> # include <cstring> # include <cstdio> # include <algorithm> # define start 0 # define end 65535 using namespace STD; char G [6] [6]; int status, CPY, how [20], path [20], times; void pre () {how [1] = 4383, how [2] = 8751, how [3] = 17487, how [4] = 34959, how [5] = 4593; How [6] = 8946, how [7] = 17652, how [8] = 35064, how [9] = 7953, how [10] = 12066; How [11] = 20292, how [12] = 36744, how [13] = 61713, how [14] = 61986; How [15] = 62532, how [16] = 63624; // bit compression storage for the area affected by the reversal of each vertex} bool DFS (INT cur, int POs, int leavings) {If (leavings = 0) {// when the combination is arranged, CPY = status; For (INT I = 0; I <Pos; ++ I) {CPY ^ = How [path [I];} if (CPY = Start) {printf ("% d \ n", times); For (INT I = 0; I <Pos; ++ I) {printf ("% d \ n", (path [I]-1)/4 + 1, (path [I]-1) % 4 + 1 );} return true;} else {return false;} else {for (in T I = cur; I <= 16; ++ I) {path [POS] = I; If (16-pos <leavings) {continue;} If (DFS (I + 1, pos + 1, leavings-1) {return true ;}return false ;}} bool OK (INT times) {If (DFS (1, 0, times )) {return true;} else {return false;} int main () {pre (); // read data for (INT I = 1; I <= 4; ++ I) {scanf ("% s", G [I] + 1); For (Int J = 1; j <= 4; ++ J) {G [I] [J] = G [I] [J] = '-'? 0: 1 ;}for (INT I = 4; I >=1; -- I) {for (Int J = 4; j> = 1; -- J) {status <= 1; if (G [I] [J]) {status | = 1; // compress the entire graph to a 32-bit number.} bool finish = false; while (! Finish) {If (OK (times) {finish = true;} else {++ times ;}} return 0 ;}