C. Statues
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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".

Output

If Maria wins, print string "WIN". If the statues win, print string "LOSE".

Examples
input
.......A
........
........
........
........
........
........
M.......
output
WIN
input
.......A
........
........
........
........
........
SS......
M.......
output
LOSE
input
.......A
........
........
........
........
.S......
S.......
MS......
output
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的更多相关文章

  1. BFS Codeforces Beta Round #94 (Div. 2 Only) C. Statues

    题目传送门 /* BFS:三维BFS,坐标再加上步数,能走一个点当这个地方在步数内不能落到.因为雕像最多8步就会全部下落, 只要撑过这个时间就能win,否则lose */ #include <c ...

  2. 图论/暴力 Codeforces Beta Round #94 (Div. 2 Only) B. Students and Shoelaces

    题目传送门 /* 图论/暴力:这是个连通的问题,每一次把所有度数为1的砍掉,把连接的点再砍掉,总之很神奇,不懂:) */ #include <cstdio> #include <cs ...

  3. Codeforces Beta Round #94 (Div. 1 Only)B. String sam

    题意:给你一个字符串,找第k大的子字符串.(考虑相同的字符串) 题解:建sam,先预处理出每个节点的出现次数,然后处理出每个节点下面的出现次数,然后在dfs时判断一下往哪边走即可,注意一下num会爆i ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  9. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

随机推荐

  1. [py][mx]django分页第三方模块django-pure-pagination

    前台的这些数据都是从后台取来的 分页模块django-pure-pagination - 一款基于django pagination封装的更好用的分页模块 https://github.com/jam ...

  2. Andrew Ng-ML-第十二章-机器学习系统设计

    1.确定执行的优先级 图1.邮件垃圾分类举例 选择100个单词作为指示是否是垃圾邮件的指标,将这些单词作为特征向量,只用0/1表示,出现多次也只用1表示,特征变量用来表示邮件. 通常情况下,会选择训练 ...

  3. 【Cocos2dx 3.3 Lua】剪裁结点ClippingNode

    参考资料:     http://shahdza.blog.51cto.com/2410787/1561937 http://blog.csdn.net/jackystudio/article/det ...

  4. css3实现头像旋转360度

    css样式: .div a img{ width: 88px; height: 88px; border-radius: 88px; transition: all 1.2s ease-out 0s; ...

  5. Impala与Hive的比较

    1. Impala架构        Impala是Cloudera在受到Google的Dremel启发下开发的实时交互SQL大数据查询工具,Impala没有再使用缓慢的Hive+MapReduce批 ...

  6. 使用Jmeter测试Dubbo接口(参数设置篇)

    WebSocket接口需要下载dubbo插件才能使用 本次下载的版本为jmeter-plugins-dubbo-1.3.6,下载完成后jar文件放到\lib\ext目录下 由于工作需要,最近需要对du ...

  7. Struts2快速后台验证 使用

    为了和前台基于JavaScript的开源验证框架RapidValidation使用统一的验证规则, 最大限度的减少重复的后台验证代码, 使用方式简便, 扩展方便. https://blog.csdn. ...

  8. sql server deadlock跟踪的四种方法

    最近写程序常会遇到deadlock victim,每次一脸懵逼.研究了下怎么跟踪,写下来记录下. 建测试数据 CREATE DATABASE testdb; GO USE testdb; CREATE ...

  9. Python Web学习笔记之Python多线程基础

    多线程理解 多线程是多个任务同时运行的一种方式.比如一个循环中,每个循环看做一个任务,我们希望第一次循环运行还没结束时,就可以开始第二次循环,用这种方式来节省时间. python中这种同时运行的目的是 ...

  10. python百分号%—%s、%d、%f

    百分号%表示占位符,在后续通过%传入真实的值 %s  拼接字符串,实际可以接受任何类型的值 %d  只能拼接整数数字 %.nf  四舍五入拼接浮点数,n表示保留到小数点后n位,不加.n默认保留6位小数 ...