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 这场的输入输出是到文件中的,不是标准的输入输出...没注意看 ...
随机推荐
- Codeforces698C. LRU
n<=20种东西,有个大小k<=n的箱子,每次会以固定的概率从所有东西里选一种,若箱子里有空位且这种东西没出现过就丢进去,若箱子满了且这种东西没出现过就把最早访问过的一个丢掉,(只要在每次 ...
- Memory Ordering in Modern Microprocessors
Linux has supported a large number of SMP systems based on a variety of CPUs since the 2.0 kernel. L ...
- webview的设置
设置支持js: webView.getSettings().setJavaScriptEnabled(true); 设置无图模式: webView.getSettings().setBlockNetw ...
- c内存分配(转)
图示 C内存分配 程序代码区 存放函数体的二进制代码 全局数据区 全局变量和静态变量的存储是放在一起的.初始化的全局变量和静态变量在一块区域,未初始化的全局变量和未初始化的静态变量在相邻的另一块区域. ...
- 调整JVM内存大小
首次运行公司项目,出现了内存溢出,具体出现java.lang.OutOfMemoryError: PermGen space和java.lang.OutOfMemoryError:GC overhea ...
- Ubuntu 16.04安装Ubuntu After Install工具实现常用软件批量安装
这个软件集成了常用且好用的软件,且只需要选择需要的软件之后自动安装好,不需要额外设置. 安装: sudo add-apt-repository ppa:thefanclub/ubuntu-after- ...
- 基于TensorFlow的图片识别服务
1.使用TensorFlow Retrain进行图片分类训练 https://www.tensorflow.org/versions/master/how_tos/image_retraining/i ...
- GETTING STARTED WITH THE OTTO JAVASCRIPT INTERPRETER
原文: https://www.fknsrs.biz/blog/otto-getting-started.html.html GETTING STARTED WITH THE OTTO JAVASCR ...
- 从Linux内核升级的必要性说开去
Linux内核更新超级频繁,可是有必要时刻升级吗?个人感觉没有必要,可是你要时刻关注新特性列表,然后把自己的内核升级到离最新版本号差一两个月公布的版本号而不是最新版本号.以保证稳定性,由于一两个月的时 ...
- Chrome查看JavaScript函数
在页面上右键view page source(Ctrl+U),然后在弹出来的界面可以查找JavaScript函数 注意:这个只能看到内嵌在网页上的JavaScript函数 一般来讲,JavaScrip ...