hdu 1072 Nightmare (bfs+贪心) (二)
.pop();
q.push(start);
node cur,next;
while(!q.empty())
{
cur=q.front();
q.pop();
for(int i=0;i<4;i++)
{
next.x=cur.x+dx[i];
next.y=cur.y+dy[i];
if(maps[next.x][next.y]==3&&cur.ltime<=1)
continue;
if(maps[next.x][next.y]==4&&cur.ltime<=1)
continue;
if(maps[next.x][next.y]==3)
return cur.steps+1;
if(maps[next.x][next.y]==4)
next.ltime=6;
else if(maps[next.x][next.y]==1)
next.ltime=cur.ltime-1;
if(cango(next)&&next.ltime>pass[next.x][next.y])
{
pass[next.x][next.y]=next.ltime;
next.steps=cur.steps+1;
q.push(next);
}
}
}
return -1;
}
int main()
{
int i,j,k,n;
scanf("%d",&n);
for(i=0;i
| 评论 |
|
|
