百练 4130 Saving Tang Monk [BFS+优先队列+状态压缩]


百练题目地址

判重3个状态就够了 位置+钥匙

除了#位置,其他位置都可以经过多次

注意钥匙数可以为零

因为打蛇要time+2,所以用优先队列

蛇的数量<=5,所以1<<5的数就足够保存蛇的状态了

#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100+5;
int N,K,vis[maxn][maxn][10];   //判重三个状态表示就够了 
int r0,c0,r1,c1;
char G[maxn][maxn];
struct Point{
	int x,y,time,key,snack;
	Point(int x,int y,int t,int k,int s):x(x),y(y),time(t),key(k),snack(s){} 
	bool operator < (const Point& p) const {
		return time>p.time;
	}
};
bool inside(int x,int y)
{
	return x>=0&&x<N&&y>=0&&y<N;
}
int bfs(int r,int 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值