直接附上代码算了。。
/**************** 连连看 *****************/
/************** 2012-11-18 ****************/
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
struct data
{
int x,y,dir,turn;
bool operator < (const data &c) const
{
return c.turn<turn;
}
};
priority_queue<data> q;
data temp,temp2;
int tempx,tempy,tempdir,tempturn,m,n,sum,x1,x2,yy1,y2;
int map[1010][1010];
int direct[4][2]={
{-1,0},{0,1},{1,0},{0,-1}};
bool already[1010][1010];
bool judge()
{
if (map[tempx][tempy]!=0) return false;
if (already[tempx][tempy]) return false;
return true;
}
void push()
{
temp2.x=tempx;
temp2.y=tempy;
temp2.dir=tempdir;
temp2.turn=tempturn;
q.push(temp2);
already[tempx][tempy]=true;
}
bool bfs()
{
if (x1<0 || x2<0 ||