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 这场的输入输出是到文件中的,不是标准的输入输出...没注意看 ...
随机推荐
- codevs 3971 航班
题目描述 Description B 国有N 座城市,其中1 号是这座国家的首都. N 座城市之间有M 趟双向航班.i 号点的转机次数定义为:从1 号点到i ,最少需要转机几 次.如果1 根本无法到达 ...
- 【Intellij】Intellij Idea 2017创建web项目及tomcat部署实战
相关软件:Intellij Idea2017.jdk16.tomcat7 Intellij Idea直接安装(可根据需要选择自己设置的安装目录),jdk使用1.6/1.7/1.8都可以,主要是配置好系 ...
- Balance POJ - 1837 地推
Gigel has a strange "balance" and he wants to poise it. Actually, the device is different ...
- P1340 兽径管理 洛谷
https://www.luogu.org/problem/show?pid=1340 题目描述 约翰农场的牛群希望能够在 N 个(1<=N<=200) 草地之间任意移动.草地的编号由 1 ...
- cogs——73. 找最佳通路
73. 找最佳通路 ★☆ 输入文件:city.in 输出文件:city.out 简单对比时间限制:1 s 内存限制:128 MB 问题描述有 n 个 城市,它们之间的交通情况已知.现在 ...
- Ubuntu 16.04升级Linux内核为4.7.0最快的方法
升级内容有很多好处,比如支持最新硬件驱动,使系统更安装等.但是升级内容也会带来一些问题,比如一些软件的兼容性问题,从而出现一些莫名其妙的问题等,所以升级时要慎重考虑. 升级方法: 下载脚本: http ...
- Elasticsearch学习系列之配置文件详解
################################### Cluster ################################### #定义集群名称,默认是elasticse ...
- CentOS 5.11开启VNC Service
1. #yum install vncserver 2. #vncpasswd 此密码将成为vnc的login password password: ...
- Nginx中配置vue,react项目地址
如题 像以前在Nginx中配置域名解析的时候只需要在conf.d文件夹下添加对应的xx.conf文件(当然了你也可以在nginx.conf)下配置. 如果是以前的老项目只需要在配置文件中server内 ...
- HDU5294 Tricks Device(最大流+SPFA) 2015 Multi-University Training Contest 1
Tricks Device Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...