---恢复内容开始---

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

Copy

.......A................................................M.......

output

Copy

WIN

input

Copy

.......A........................................SS......M.......

output

Copy

LOSE

input

Copy

.......A.................................S......S.......MS......

output

Copy

LOSE、

蛮水的一道BFS,我用BFS写的,DFS也可,我比较菜,对着数据改了好几回QAQ

char mp[101][101];
int x[65],y[65],top=0;
vector <int> vec[105];
int dx[]={0,0,1,-1,-1,1,1,-1,0},dy[]={1,-1,0,0,-1,1,-1,1,0};
struct inof{
int x,y,Step;
}temp;
queue <inof> P;
int vis[64][64][1000];
bool check(int x,int y, int Step)
{
// if(x==0&&y==2)printf("OOOO((((\n");
if(x<0||y<0||x>=8||y>=8)return false;
if(vis[x][y][Step+1])return false;
int siz = vec[y].size();
for(int i=0;i<siz;i++)
{
int tim = x-vec[y][i];
//if(x==0&&y==2)printf("%d^^^%d\n",tim,Step);
/// printf("1");
if(tim<0)continue;
if(tim==Step+1)return false;
if(tim==Step)return false;
}
return true;
}/*
bool che(int x,int y,int Step)
{
int siz = vec[y].size();
for(int i=0;i<siz;i++)
{
int tim = x-vec[y][i];
if(tim==Step+1)return false;
}
return true;
}*/
int main() {
memset(vis,0,sizeof(vis));
for(int i=0;i<8;i++)cin>>mp[i];
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
if(mp[i][j]=='S')vec[j].push_back(i);
}
}
temp.x=7,temp.y=0,temp.Step=0;
P.push(temp);
while(!P.empty()){
temp = P.front();P.pop(); //if(temp.x==0&&temp.y==1)printf("&&&&&&&&&\n");
//if(!(che(temp.x,temp.y,temp.Step)))continue;
if(mp[temp.x][temp.y]=='A')return 0*printf("WIN");

for(int i=0;i<9;i++){
///printf("1");
int x = temp.x+dx[i],y = temp.y+dy[i];

if(check(x,y,temp.Step))
{
//printf("%d %d\n",x,y);
inof tem;tem.x=x,tem.y=y,tem.Step=temp.Step+1;
P.push(tem);
vis[x][y][temp.Step]=1;
}
}
}
puts("LOSE");
return 0;
}

转载于:https://www.cnblogs.com/DreamKill/p/9347587.html

Codeforces Beta Round #94 (Div. 1 Only)A. Statues相关推荐

  1. Codeforces Beta Round #75 (Div. 1 Only) B. Queue 线段树。单点更新

    http://codeforces.com/problemset/problem/91/B 题意: 给你n个数,求得i 到n中小于a[i]的最右边的a[j],然后求a[i]到a[j]之间包含了多少个数 ...

  2. Codeforces Beta Round #22 (Div. 2 Only) E. Scheme(DFS+强连通)

    题目大意 给了 n(2<=n<=105) 个点,从每个点 u 出发连向了一个点 v(共 n 条边) 现在要求添加最少的边使得整个图是一个强连通图 做法分析 这道题千万不要一般化:先求强连通 ...

  3. Codeforces Beta Round #4 (Div. 2 Only)

    Codeforces Beta Round #4 (Div. 2 Only) A 水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 ...

  4. Codeforces Beta Round #92 (Div. 1 Only) A. Prime Permutation 暴力

    A. Prime Permutation 题目连接: http://www.codeforces.com/contest/123/problem/A Description You are given ...

  5. Codeforces Beta Round #9 (Div. 2 Only) D. How many trees? dp

    D. How many trees? 题目连接: http://www.codeforces.com/contest/9/problem/D Description In one very old t ...

  6. Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题

    B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...

  7. Codeforces Beta Round #96 (Div. 1) D. Constants in the language of Shakespeare 贪心

    D. Constants in the language of Shakespeare Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codef ...

  8. Codeforces Beta Round #9 (Div. 2 Only) C. Hexadecimal's Numbers dfs

    C. Hexadecimal's Numbers 题目连接: http://www.codeforces.com/contest/9/problem/C Description One beautif ...

  9. Codeforces Beta Round #16 (Div. 2 Only)【未完结】

    2022.3.9 题目地址:https://codeforces.com/contest/16 目录 A. Flag[模拟] B. Burglar and Matches[贪心] C. Monitor ...

  10. Codeforces Beta Round #14 (Div. 2)【未完结】

    2022.3.8 题单地址:https://codeforces.com/contest/14 目录 A. Letter B. Young Photographer[差分] C. Four Segme ...

最新文章

  1. docker 搭建私有仓库
  2. python3用什么系统好_学python用什么系统【怎么学好python】
  3. 黑马程序员C语言基础(第六天)指针
  4. CSS块元素水平垂直居中的实现技巧
  5. 选防晒霜 要看四个要点 - 健康程序员,至尚生活!
  6. nginx设置http强制跳转https
  7. android学习笔记---60_meta-data的使用,在清单文件中是用meta-data来给activity,service,receiver提供参数
  8. adb模拟按键home_ADB——模拟手机按键输入
  9. Scikit-learn:模型评估Model evaluation 之绘图
  10. 计算机考研视频哪个机构的好,计算机考研辅导视频十大排名
  11. 构建自己的Conficker
  12. 伯克利CS61A-Sum2019-Week1
  13. 计算机系统u盘判断,U盘真实容量检测工具
  14. 南京大学俞扬博士:强化学习前沿(下)
  15. 龙格-库塔(Runge-Kutta)
  16. Jetson TK1
  17. linux读取excel文件内容,如何读取EXCEL文件到内表
  18. 语音转换成文本 技术实现_职业转换者指南,帮助您实现梦想的技术工作
  19. PS图层混合算法之四(亮光, 点光, 线性光, 实色混合)
  20. tensorrt遇到torch.bmm的解决

热门文章

  1. Linux 修改环境变量设置的三种方式
  2. linux怎么看网络连接网络,linux如何查看网络连接情况?
  3. python问题 Traceback (most recent call last)
  4. fedora 11源码安装设置fcitx3.6输入法
  5. 如何在亿级数据中判断一个元素是否存在?
  6. 2012年最具影响力路由器配置精品文章荟萃【108篇】
  7. Linux 别名设置,可一键登入服务器- alias
  8. 计算机内存不足无法打印照片,打印机内存不足无法打印怎么办_打印机提示内存不足怎么解决...
  9. redis持久化(persistent)
  10. C语言编程练习:猜数游戏