程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> POJ - 1324 Holedox Moving

POJ - 1324 Holedox Moving

編輯:C++入門知識

題意:貪吃蛇的題目

思路:BFS+狀態的記錄,坑了無數發,

#include
#include
#include
using namespace std;
const int MAXN = 500000;
bool flag[8],vis[25][25],mp[21][21][16384];
int n,m,l;
int xx[4]={-1,0,1,0}; // up,right,dow,left
int yy[4]={0,1,0,-1};
int front,rear;
struct Node
{
	int x,y;
	int step;
	int s[8];
	int p[8][2];
};
Node q[MAXN];
int _pre(int sx,int sy,int _x,int _y)
{
	int x=_x-sx,y=_y-sy;
	if(x==-1) return 0;
	else if(x==1) return 2;
	else if(y==-1) return 1;
	return 3;
}
int adss(Node G)
{
	int va=G.s[0],vb=1,i;
	for(i=1;i=n || y>=m || vis[x][y]) continue;
			if(itself(x,y,q[front])) continue;
			rear=(rear+1)%MAXN;
			q[rear].x=x,q[rear].y=y,q[rear].step=q[front].step+1;
			for(int j=0;j

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved