AMR11G - 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!

 

 


Added by:Varun Jalan
Date:2011-12-15
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Varun Jalan - ICPC Asia regionals, Amritapuri 2011

hide comments
2016-01-12 19:01:35 Alexis Lozano Terán
Solo basta con leer los ejemplos de entrada y salida para deducir el problema :v
2015-02-24 12:33:09 (Tjandra Satria Gunawan)(曾毅昆)
@Ouditchya Sinha: Thank you ^_^ I think it's a naturally gifted talent :) Thanks to the god and the universe!
2014-01-13 15:41:37 Samil Vargas
i didnt read the description XD too easy
2013-09-02 19:01:45 Ouditchya Sinha
@Tjandra : Wow! You didn't know any programming language 2 years ago & now you are World Rank 23? Truly an inspiration! Hats off to you... :)
2013-04-12 10:23:22 (Tjandra Satria Gunawan)(曾毅昆)
I'm late ~2 years to solve this problem using brainf**k :-P but, 2 years ago, I don't familiar with any programming language..
2013-01-15 07:02:14 Amit
tutorial problem...
2012-04-23 08:07:50 srikanth reddy
tutorial plz!!
2012-01-12 19:36:44 Santiago Palacio
Move to tutorial.
2012-01-07 12:37:45 hendrik
Aditya: Not hard for you but perhaps for someone else. Posting solutions here is stupid.
2011-12-27 16:05:07 Aditya Muttur
Tutorial Problem. Really Simple.
@AiRnAsH: Harry can't go through segment if he comes across a dragon(D) anywhere. Otherwise he can. Thats all.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.