int dy[8] = {-2, -2, -1, -1, 1, 1, 2, 2}; int marked[MAX][MAX]; //标记 int pathx[MAX]; int pathy[MAX]; int flag, step; int p,q; int main(void) { int n; int i = 0; int j, k; scanf("%d", &n); while (i++ < n) { scanf("%d%d", &p, &q); for ...
using namespace std; int p, q, cnt, flag; int vis[MAXN][MAXN], path[MAXN*MAXN][2]; int dir[8][2] = {{-1,-2}, {1,-2}, {-2,-1}, {2,-1}, {-2,1}, {2,1}, {-1,2}, {1,2}}; void dfs(int x, int y, int step) { if(step == p*q) { cout << "S...
http://poj.org/problem?id=2488 给一个n1*n2的棋盘,从(0,0)出发,每次走日字形,能否不重复的遍历所有的点 用DFS即可,需要注意搜索的方向要按字典序 #include<stdio.h> #include<string.h> #include<stdlib.h> int n1,n2; int xx[30],yy[30]; int visit[30][30]; int flag; int dir[8][2]=...
http://poj.org/problem?id=2488 Description Background The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the world. Whenever a knight moves, it is two squares in one direction and one square perpendicular to this...
intf[2][8]={{-2,-2,-1,-1,1,1,2,2}, {-1,1,-2,2,-2,2,-1,1}}; structnode{ intx,y; }mp[30]; voiddfs(intx,inty,intstep,intt) { if(flag)return; vis[x][y]=1; mp[step].x=x; mp[step].y=y; if(step==p*q&&flag==0) ...
题目链接:http://poj.org/problem?id=2488 A Knight's Journey Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 36695 Accepted: 12462 Description BackgroundThe knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around ...
POJ-2488,A Knight's Journey(DFS) Description: Background The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the world. Whenever a knight moves, it is two squares in one direction and one square perpendicular to ...
POJ 2488(简单的深搜) 1. re: Pku 2774--Long Long Message(后缀树) 求教大牛,那个Lt属性是记录什么的 --dereky 2. re: POJ 2481(树状数组) @gzwzm06 哦,实在是不好意思,确实是那个地方,现在过了,谢谢了啊。 --Klion 3. re: POJ 2481(树状数组)...
#include<stdio.h>#include<string.h>usingnamespacestd;/*★POJ2488 骑士的旅程 解法一*/intcases;constintMAX_N=30;boolvisited[MAX_N][MAX_N];//字典序最小的行走方向// y从上到下,x从左到右进行变化,就可以满足字典序constintdx[8]={-1,1,-2,2,-2,2,-1,1};constintdy[8]={-2,-2,-...
POJ 2488 A Knight's Journey 题解 A Knight's Journey Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26210 Accepted: 8950 Description Background The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey ...