Describe
On a 4x5 board, the position of the horse's starting position coordinates (longitudinal, transverse) is entered by the keyboard, and the horse can return to the total number of different methods of the initial position (the horse passes the position can not be repeated, the horse Walk "Day" word).
Input
Input file first behavior test Case number N, next n rows, two positive integers per line x, y (1<=x<=5,1<=y<=6), represents the position coordinates of the horse .
Output
The output of each test case is one row, and the output horse can return the total number of all different walks in its initial position, and if not, output "ERROR" (without double quotes).
Sample input
3
2 2
1 1
4 6
Sample output
4596
1508
ERROR
1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 intm, N;6 intdx[]={1,1,-1,-1,2,2,-2,-2};7 intdy[]={2,-2,2,-2,1,-1,1,-1};8 intmap[5][6];9 intSX, Sy, step;Ten One voidDfsintXinty) A { - intxx, yy, I; - for(i =0; I <8; i++) the { -xx = x +Dx[i]; -yy = y +Dy[i]; - if(xx>=0&& yy>=0&& xx<4&& yy<5&& Map[xx][yy] = =0) + { -MAP[XX][YY] =1; + DFS (XX,YY); AMAP[XX][YY] =0; at } - if(xx+1==sx&&yy+1==Sy) -step++; - } - } - in intMain () - { to intN; + while(cin>>N) - { the while(n--) * { $Cin>>sx>>Sy;Panax Notoginseng if(sx<1|| Sx>4|| sy<1|| Sy>5) - { theprintf"error\n"); + Continue; A } thememset (Map,0,sizeofmap); +Step =0; -map[sx-1][sy-1] =1; $DFS (sx-1, sy-1); $printf"%d\n", step); - } - } the return 0; -}
The way of the horse