BFS Codeforces Beta Round #94 (Div. 2 Only) C. Statues
/*
BFS:三维BFS,坐标再加上步数,能走一个点当这个地方在步数内不能落到。因为雕像最多8步就会全部下落,
只要撑过这个时间就能win,否则lose
*/
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>
using namespace std; const int MAXN = ;
const int INF = 0x3f3f3f3f;
struct Point{
int x, y, step;
};
char maze[MAXN][MAXN];
bool vis[MAXN][MAXN][MAXN];
int n; bool check(int x, int y, int s) {
if (x >= && x <= && y >= && y <= && maze[x-s][y] != 'S') return true;
return false;
} bool BFS(void) {
queue<Point> Q; Q.push ((Point) {, , });
memset (vis, false, sizeof (vis)); while (!Q.empty ()) {
int x = Q.front ().x, y = Q.front ().y, s = Q.front ().step; Q.pop (); if (s > ) return true;
if (maze[x-s][y] == 'S') continue; for (int i=-; i<=; ++i) {
for (int j=-; j<=; ++j) {
int tx = x + i; int ty = y + j;
if (!check (tx, ty, s)) continue;
if (!vis[tx][ty][s+]) {
vis[tx][ty][s+] = true;
Q.push ((Point) {tx, ty, s + });
}
}
}
} return false;
} int main(void) { //Codeforces Beta Round #94 (Div. 2 Only) C. Statues
//freopen ("B.in", "r", stdin); n = ;
while (scanf ("%s", maze[] + ) == ) {
for (int i=; i<=n; ++i) {
scanf ("%s", maze[i] + );
} if (BFS ()) puts ("WIN");
else puts ("LOSE");
} return ;
}
BFS Codeforces Beta Round #94 (Div. 2 Only) C. Statues的更多相关文章
- 图论/暴力 Codeforces Beta Round #94 (Div. 2 Only) B. Students and Shoelaces
题目传送门 /* 图论/暴力:这是个连通的问题,每一次把所有度数为1的砍掉,把连接的点再砍掉,总之很神奇,不懂:) */ #include <cstdio> #include <cs ...
- Codeforces Beta Round #94 div 2 C Statues dfs或者bfs
C. Statues time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...
- Codeforces Beta Round #94 (Div. 1 Only)B. String sam
题意:给你一个字符串,找第k大的子字符串.(考虑相同的字符串) 题解:建sam,先预处理出每个节点的出现次数,然后处理出每个节点下面的出现次数,然后在dfs时判断一下往哪边走即可,注意一下num会爆i ...
- Codeforces Beta Round #94 div 1 D Numbers map+思路
D. Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...
- Codeforces Beta Round #94 div 2 B
B. Students and Shoelaces time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #70 (Div. 2)
Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #55 (Div. 2)
Codeforces Beta Round #55 (Div. 2) http://codeforces.com/contest/59 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #35 (Div. 2)
Codeforces Beta Round #35 (Div. 2) http://codeforces.com/contest/35 A 这场的输入输出是到文件中的,不是标准的输入输出...没注意看 ...
随机推荐
- Multiprocessing system employing pending tags to maintain cache coherence
A pending tag system and method to maintain data coherence in a processing node during pending trans ...
- spring SSH整合
1 导入三大框架依赖的包: 2 配置web.xml: 增加spring的OpenSessionInView过滤器让Spring管理Session保证Session在一个完整的请求过程是开着的,要配置S ...
- [TypeScript] Collect Related Strings in a String Enum in TypeScript
As of TypeScript 2.4, it is now possible to define string enums, or more precisely, enums with strin ...
- Androidbuttonshape形状资源码实现
1.项目Src下创建drawable 看文档Develop/API Guides/App Resources/Drawable/Shape Drawable 单词:corners : 角 ; gr ...
- linux 下使用genymotion
在官网下载genymotion http://www.genymotion.cn/ 然后进行下面操作 1.假设本机没有virtualbox 下载一个 能够通过指令 sudo apt-get inst ...
- osg提前定义几何体设置颜色
注意尽管osg::shape不能够设置颜色,可是osg::shapedrawable能够.
- PHP导入和导出CSV文件
CREATE TABLE `student` ( `id` ) NOT NULL auto_increment, `name` varchar() NOT NULL, `sex` varchar() ...
- mac 查看python路径
1,terminal : input: which python 2, terminal: input : python --->import sys ----> print sys ...
- Eclipse Android环境配置
1.离线安装ADT插件,先将ZIP包下载 Help- Install New Software- Add 重启 2.WIndows -Preference设置SDK目录
- Spring Boot Controller
接上篇文章.HelloWorld程序中我们已经创建了一个HellController,里面包括了响应JSON的方法.本文针对Controller再做一下解说. 回想上篇文章,我们在Controller ...