洛谷——打开灯泡——P4667

首先(我似乎只会这样写 )看一下题叭:
P4667 [BalticOI 2011 Day1]Switch the Lamp On
首先这道题要用广搜做,不过这里要用点而不是格,所以注意要把格转化为点。其次,因为我们遍历的点而不是格,所以有6个方向要进行遍历,可以遍历上下左右,另外两个方向依据情况而定。我们可以定义一个数组,既可以当做标记,也可以当做cnt来用。
代码如下:

#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <map>
#define inf 0x7ffffff
#define ll long long
//#include <windows.h>
//#include <bits/stdc++.h>
using namespace std;
/*
输入:

输出:

*/
int n,m;//n*m
char map1[601][601];
struct node {
   
	int x,y,step;
} wer;
int book[601][601];
deque <node> q;
   1:左上 ,2:左下,3:右上,4:右下
int nxtx[10]= {
   0,-1,1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值