G is the most watery

Source: Internet
Author: User

 

G-here be dragons

The Triwizard Tournament's third task is to negotiate a corridor of specified 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 '. 'If the segment is empty, or a' 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 <= 501 <= n <= 50 time limit: 1 smemory limit: 32 mbsample input: 3 .... d. D .. dsample output: possibleyou shall not pass! You shall not pass!

 

The Triwizard Tournament's third task is to negotiate a corridor of specified 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 indicates an obstacle. You can pass the obstacle.

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.