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!

 #include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
char a[];
int n,flag=;
scanf("%d",&n);
for(int i=;i<n;i++)
{
flag=;
cin>>a;
int m=strlen(a);
for(int l=;l<m;l++)
{
if(a[l]=='D')
{
flag=-;
printf("You shall not pass!\n");
break;
}
}
if(flag==)
printf("Possible\n");
}
return ;
}

SPOJ 10234. Here Be Dragons的更多相关文章

  1. BZOJ 2588: Spoj 10628. Count on a tree [树上主席树]

    2588: Spoj 10628. Count on a tree Time Limit: 12 Sec  Memory Limit: 128 MBSubmit: 5217  Solved: 1233 ...

  2. SPOJ DQUERY D-query(主席树)

    题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ...

  3. SPOJ GSS3 Can you answer these queries III[线段树]

    SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...

  4. 【填坑向】spoj COT/bzoj2588 Count on a tree

    这题是学主席树的时候就想写的,,, 但是当时没写(懒) 现在来填坑 = =日常调半天lca(考虑以后背板) 主席树还是蛮好写的,但是代码出现重复,不太好,导致调试的时候心里没底(虽然事实证明主席树部分 ...

  5. SPOJ bsubstr

    题目大意:给你一个长度为n的字符串,求出所有不同长度的字符串出现的最大次数. n<=250000 如:abaaa 输出: 4 2 1 1 1 spoj上的时限卡的太严,必须使用O(N)的算法那才 ...

  6. 【SPOJ 7258】Lexicographical Substring Search

    http://www.spoj.com/problems/SUBLEX/ 好难啊. 建出后缀自动机,然后在后缀自动机的每个状态上记录通过这个状态能走到的不同子串的数量.该状态能走到的所有状态的f值的和 ...

  7. 【SPOJ 1812】Longest Common Substring II

    http://www.spoj.com/problems/LCS2/ 这道题想了好久. 做法是对第一个串建后缀自动机,然后用后面的串去匹配它,并在走过的状态上记录走到这个状态时的最长距离.每匹配完一个 ...

  8. 【SPOJ 8222】Substrings

    http://www.spoj.com/problems/NSUBSTR/ clj课件里的例题 用结构体+指针写完模板后发现要访问所有的节点,改成数组会更方便些..于是改成了数组... 这道题重点是求 ...

  9. SPOJ GSS2 Can you answer these queries II

    Time Limit: 1000MS   Memory Limit: 1572864KB   64bit IO Format: %lld & %llu Description Being a ...

随机推荐

  1. torchvision简介

    安装pytorch时,torchvision独立于torch.torchvision包由流行的数据集(torchvision.datasets).模型架构(torchvision.models)和用于 ...

  2. Python函数:对变量赋值,变量即局部

    b = 6 def f2(a): print(a) print(b) b = 9 UnboundLocalError: local variable 'b' referenced before ass ...

  3. NVME SSD vs SATA SSD(转)

    NVMe是个啥?未来SSD主流标准早知 关注固态硬盘的朋友应该对于这个词汇并不陌生,特别是今年NVMe也频繁出现在各大媒体文章中,随着高端SSD市场逐渐从SATA专项PCI-E时,以前的AHCI标准已 ...

  4. Windows Phone 8 获取设备名称

    通过使用Microsoft.Phone.Info.DeviceStatus类,我们可以获取设备的一些信息,如设备厂商,设备名称等.通过Microsoft.Phone.Info.DeviceStatus ...

  5. js权威指南---学习笔记02

    1.JS只有函数作用域,没有块级作用域这个概念: 它有一个特性——声明提前:在同一个函数中不同位置声明的变量,都被提前在函数开始的时候,执行声明操作:在原先位置执行赋值操作: 2.声明的全局变量,相当 ...

  6. JVM性能调优监控工具——jps、jstack、jmap、jhat、jstat、hprof使用详解

    摘要: JDK本身提供了很多方便的JVM性能调优监控工具,除了集成式的VisualVM和jConsole外,还有jps.jstack.jmap.jhat.jstat.hprof等小巧的工具,本博客希望 ...

  7. 在 SQL Server 2005 中配置数据库邮件

    一.            SQL Server发邮件原理和组件介绍: 数据库邮件有4个组件:配置文件.邮件处理组件.可执行文件以及“日志记录和审核组件”. l  配置组件包括: 1)数据库邮件帐户包 ...

  8. Knockout.Js官网学习(模版绑定)

    模板绑定器 如今页面结构越来越复杂,仅仅依靠foreach已经不足以我们的使用,这个时候我们就需要模板的存在,模板的优点自然很多,首先会让页面整洁,同时修改起来也可以方面的定位,最重要的是ko可以条件 ...

  9. java遍历ftp文件夹下所有文件(或指定文件下的文件)

    import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import org.apach ...

  10. Android Studio编译慢、卡死和狂占内存怎么破?

    https://www.zhihu.com/question/27953288 作者:知乎用户链接:https://www.zhihu.com/question/27953288/answer/118 ...