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