A-A+

Fox Ciel

2014年07月14日 acm未分类 暂无评论 阅读 59 次

Fox Ciel

时间限制:1000 ms  |  内存限制:65535 KB
难度:2
描述
Fox Ciel is going to take a path to meet her friends. The path is tiled with 1x1 square tiles. It is N tiles long and 2 tiles wide. If we imagine that the path is going from the left to the right, we can view it as a rectangle with 2 rows and N columns of tiles. The rows of the path are numbered 0 to 1 from top to bottom, and the columns of the path are numbered 0 to N-1 from left to right. Ciel starts at the tile in row 0, column 0. She has to reach the tile in row 0, column N-1.In each step, Ciel can move to an adjacent tile. Two tiles are adjacent if they share at least one point (a side or a corner).Because it rained yesterday, some tiles are covered by puddles of water. Ciel will not step on these tiles. Each character is 'W' if the tile is covered by water, and '.' otherwise.

输入
The constraints guarantee that the starting tile and the destination tile are never covered by water.
T indicates T(1<T<100) cases,The path is N tiles long.(1<N<500)
输出
Print "YES" if she can move to her destination without entering a tile which is filled with water. Otherwise, Print "NO".
样例输入
[/cpp]2
8
....W...
W.......
2
..
..
样例输出
[/cpp]YES
YES

这一题不难,前提你能看懂英文的情况下,代码不是我写的,校赛三人组!
[cpp]
#include<iostream>
using namespace std;
#define Max 500
int main()
{
int i,n,N,flg;
char Tiles[2][Max];
cin>>n;
while(n--)
{
cin>>N;
for(i = 0; i < 2; i++)
{
for(int j = 0; j < N; j++)
{
cin>>Tiles[i][j];
}
}
for(i=0;i<=N-1;i++)
{
flg=1;
if(Tiles[0][0]== 'W' || Tiles[0][N-1] == 'W')
{
flg=0;
break;
}
if(Tiles[0][i]=='W' && Tiles[1][i]=='W')
{
flg=0;
break;
}
}
if(flg==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}

[/cpp]

标签:

给我留言

Copyright © C/C++程序员之家 保留所有权利.   Theme  Ality 浙ICP备15011757号-3

用户登录