G - Here Be Dragons

The Triwizard Tournament's third task is to negotiate a corridor of many segments, and reach the other end. The corridor is N segments long. The ith segment is either empty or has a dragon. Harry cannot pass the dragon and will have no option but to retreat if he encounters one. Is it possible for him to reach the exit starting from the entrance?

Input (STDIN):
The first line contains the number of test cases T.
Each of the next T lines contains a string describing the corridor. The ith character is either a '.' if the segment is empty, or a 'D' if the segment contains a dragon.
Output (STDOUT):
Output T lines, each containing either the string "Possible" if you can reach the exit, and "You shall not pass!" if it is not possible to reach the exit.
Constraints:
1 <= T <= 50
1 <= N <= 50
Time Limit: 1 s
Memory Limit: 32 MB
Sample Input:
3
..
..D.
D..D
Sample Output:
Possible
You shall not pass!
You shall not pass!

The Triwizard Tournament's third task is to negotiate a corridor of many segments, and reach the other end. The corridor is N segments long. The ith segment is either empty or has a dragon. Harry cannot pass the dragon and will have no option but to retreat if he encounters one. Is it possible for him to reach the exit starting from the entrance?

Input (STDIN):

The first line contains the number of test cases T.

Each of the next T lines contains a string describing the corridor. The ith character is either a '.' if the segment is empty, or a 'D' if the segment contains a dragon.

Output (STDOUT):

Output T lines, each containing either the string "Possible" if you can reach the exit, and "You shall not pass!" if it is not possible to reach the exit.

Constraints:

1 <= T <= 50

1 <= N <= 50

Sample Input:

3

..

..D.

D..D

Sample Output:

Possible

You shall not pass!

You shall not pass!

题意:D表示障碍 .表示可以通过  障碍不可以通过  问是否可以走过路线

#include <iostream>
#include <string.h>
#include <stdio.h> using namespace std; int main()
{
char a[];
int t;
bool OK;
scanf("%d",&t);
while(t--)
{
scanf("%s",&a);
OK=false;
int len=strlen(a);
for(int i=; i<len; i++)
{
if(a[i]=='D')
{
OK=true;
break;
}
}
if(OK)
printf("You shall not pass!\n");
else
printf("Possible\n");
}
return ;
}

最新文章

  1. 七天学会ASP.NET MVC (二)——ASP.NET MVC 数据传递
  2. PHP Fatal Error: call to undefined function mysql_connect() [duplicate]
  3. 常用meta标签举例说明
  4. URAL 1152. False Mirrors(DP)
  5. Maven&amp;&amp;Ant使用
  6. Omnet++ 4.0 入门实例教程
  7. keyup、keydown和keypress
  8. failed to obtain a cell from its dataSource
  9. mysqli和mysql和pdo查询
  10. EF-CodeFirst-表关系-延迟/贪婪加载
  11. [MVC4-基礎] 連動DropDownList - 使用jQuery、JSON
  12. hardware_hp存储映射_方案
  13. 使用Windows2003创建DNS服务器 - 进阶者系列 - 学习者系列文章
  14. lamp环境搭建经验总结
  15. EntityFramework+EntityFramework.SqlServerCompact部署网站
  16. react 报错的堆栈处理
  17. Python编程练习:使用 turtle 库完成玫瑰花的绘制
  18. Linux_CentOS-服务器搭建 &lt;五&gt; 补充
  19. C++ 并发编程,std::unique_lock与std::lock_guard区别示例
  20. 【封装函数】当前元素距离html文档顶部距离

热门文章

  1. LibreOJ #6001. 「网络流 24 题」太空飞行计划 最大权闭合图
  2. PDF下载网
  3. springboot server.address 配置问题
  4. centos配置备忘(apache\php\mysql)
  5. mybatis学习四 mybatis的三种查询方式
  6. centos7 sqoop 1 搭建笔记
  7. Oracle启动两个监听
  8. Codeforces Round #542(Div. 2) CDE 思维场
  9. zl
  10. Andrew机器学习第一课