Codeforces Beta Round #94 div 2 C Statues dfs或者bfs
2 seconds
256 megabytes
standard input
standard output
In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. A square that contains a statue cannot have anything or anyone — neither any other statues, nor Anna, nor Maria.
Anna is present on the board as a figurant (she stands still and never moves), and Maria has been actively involved in the game. Her goal is — to come to Anna's square. Maria and statues move in turn, Maria moves first. During one move Maria can go to any adjacent on the side or diagonal cell in which there is no statue, or she can stay in the cell where she is. The statues during their move must go one square down simultaneously, and those statues that were in the bottom row fall from the board and are no longer appeared.
At that moment, when one of the statues is in the cell in which the Maria is, the statues are declared winners. At the moment when Maria comes into the cell where Anna has been waiting, Maria is declared the winner.
Obviously, nothing depends on the statues, so it all depends on Maria. Determine who will win, if Maria does not make a strategic error.
You are given the 8 strings whose length equals 8, describing the initial position on the board. The first line represents the top row of the board, the next one — for the second from the top, and so on, the last line represents the bottom row. Each character string matches a single cell board in the appropriate row, and the characters are in the same manner as that of the corresponding cell. If the cell is empty, the corresponding character is ".". If a cell has Maria, then it is represented by character "M". If a cell has Anna, it is represented by the character "A". If a cell has a statue, then the cell is represented by character "S".
It is guaranteed that the last character of the first row is always "A", the first character of the last line is always "M". The remaining characters are "." or "S".
If Maria wins, print string "WIN". If the statues win, print string "LOSE".
.......A
........
........
........
........
........
........
M.......
WIN
.......A
........
........
........
........
........
SS......
M.......
LOSE
.......A
........
........
........
........
.S......
S.......
MS......
LOSE
题意:给你一个8*8的图;每过一秒S下降一格;M可以八个方向加静止不动的走;不能能碰到S。(A有什么用。。。)
思路:M撑过8秒;
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
#define true ture
#define false flase
using namespace std;
#define ll __int64
#define inf 0xfffffff
int scan()
{
int res = , ch ;
while( !( ( ch = getchar() ) >= '' && ch <= '' ) )
{
if( ch == EOF ) return << ;
}
res = ch - '' ;
while( ( ch = getchar() ) >= '' && ch <= '' )
res = res * + ( ch - '' ) ;
return res ;
}
char a[][],ans;
int check(int x,int y)
{
if(x<=||x>||y<=||y>)
return ;
return ;
}
void dfs(int x,int y,int step)
{
if(step>)
{
ans=;
return;
}
for(int i=-;i<=;i++)
for(int t=-;t<=;t++)
{
if(ans)
break;
int xx=x+i;
int yy=y+t;
if(check(xx,yy)&&a[xx-step][yy]!='S'&&a[xx-step-][yy]!='S')
dfs(xx,yy,step+);
}
}
int main()
{
int x,y,z,i,t;
for(i=;i<=;i++)
for(t=;t<=;t++)
cin>>a[i][t];
dfs(,,);
if(ans)
printf("WIN\n");
else
printf("LOSE\n");
return ;
}
Codeforces Beta Round #94 div 2 C Statues dfs或者bfs的更多相关文章
- BFS Codeforces Beta Round #94 (Div. 2 Only) C. Statues
题目传送门 /* BFS:三维BFS,坐标再加上步数,能走一个点当这个地方在步数内不能落到.因为雕像最多8步就会全部下落, 只要撑过这个时间就能win,否则lose */ #include <c ...
- 图论/暴力 Codeforces Beta Round #94 (Div. 2 Only) B. Students and Shoelaces
题目传送门 /* 图论/暴力:这是个连通的问题,每一次把所有度数为1的砍掉,把连接的点再砍掉,总之很神奇,不懂:) */ #include <cstdio> #include <cs ...
- 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 #95 (Div. 2) D. Subway dfs+bfs
D. Subway A subway scheme, classic for all Berland cities is represented by a set of n stations conn ...
- 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 #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
随机推荐
- angular $scope.$watch
在$scope内置的所有函数中,用得最多的可能就是$watch 函数了.当你的数据模型中某一部分发生变化时,$watch函数可以向你发出通知. 你可以监控单个对象的属性,也可以监控需要经过计算的结果( ...
- [lr] 直方图
直方图基础知识 • 直方图的特征和作用 ▪ 直方图的x轴从左到右代表亮度逐渐增加,即从最暗到最亮:y轴代表某个亮度值下颜色像素的多少(密度). ▪ 直方图由红绿蓝三种颜色组成,分别表示红绿蓝通道:其中 ...
- 使用jmeter进行websocket协议压测
第一步:添加websocket sampler组件 可以使用plugins manager进行添加,首先下载plugins manager组件: 下载路径: https://jmeter-plugi ...
- 1:4 UI标签和通用标签
UI标签:负责用户界面输出的标签. 非标单:例如错误信息提示的标签 fielderror,actionerror,actionmessagr:系统错误消息的自动显示 通 ...
- STA分析(一) setup and hold
timing check可以分为Dynamic Timing Analysis(Post_sim)和Static Timing Analysis STA:可以分析的很全面:仿真速度也很快:可以分析控制 ...
- 学号20155311 2016-2017-2 《Java程序设计》第9周学习总结
学号 2016-2017-2 <Java程序设计>第9周学习总结 教材学习内容总结 整合数据库 JDBC(Java DataBase Connectivity)即java数据库连接,是一种 ...
- Assets.xcassets 应用
1.应用 Assets.xcassets :用来存放图像资源文件 给项目添加 AppIcon 时图标要用 png 格式的,不要用其他格式.当是其它图片格式时 ,不要仅仅修改其后缀名,若仅仅修改后缀名, ...
- 奋斗史-IT女生是怎样炼成的
IT女生的奋斗史 终于来到了毕业季,感觉有点伤感! 记得11年来到大学的时候,还是那么懵懂,什么都不懂,几乎连电脑的基本操作都不会!自己小时候虽然家里穷,但是从小就觉得“软件”是个很神奇的东西,很了不 ...
- python 换行符的识别问题,Unix 和Windows 中是不一样的
关于换行符的识别问题,在Unix 和Windows 中是不一样的(分别是n 和rn).默认情况下,Python 会以统一模式处理换行符.这种模式下,在读取文本的时候,Python 可以识别所有的普通换 ...
- Hive 复制分区表和数据
1. 非分区表: 复制表结构: create table new_table as select * from exists_table where 1=0; 复制表结构和数据: create tab ...