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?

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[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;
}

G 最水的一道

时间: 2024-10-28 15:38:44

G 最水的一道的相关文章

hdu 5038 (2014北京网络赛G 排序水题)

题意:有n个数字,带入10000 - (100 - ai) ^ 2公式得到n个数,输出n个数中频率最大的数,如果有并列就按值从小到大都输出输出,如果频率相同的数字是全部的n个数,就输出Bad....题解:统计数字个数和频率,排序后输出. Sample Input36100 100 100 99 98 1016100 100 100 99 99 1016100 100 98 99 99 97 Sample OutputCase #1:10000Case #2:Bad MushroomCase #3

【Virtual Judge】G - 一般水的题2-Approximating a Constant Range

Description When Xellos was doing a practice course in university, he once had to measure the intensity of an effect that slowly approached equilibrium. A good way to determine the equilibrium intensity would be choosing a sufficiently large number o

Hard??没搞错吧,LeetCode水题一道:Find Minimum in Rotated Sorted Array II

做完Find Minimum in Rotated Sorted Array I觉得很简单,再做2发现也不难,但是LeetCode竟然给了一个hard评级,难道是我编程水平大有长进?哈哈我估计是对复杂度有很高的要求的情况下比较难吧.. Python(偷懒)做法就是一句话:return min(num) Java(基本做法)如下: public class Solution { public int findMin(int[] num) { int len=num.length; if (len=

超水的一道最短路poj2387

Til the Cows Come Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 68667   Accepted: 23016 Description Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the

[ZPG TEST 114] 阿狸的英文名【水题】

1.      阿狸的英文名 阿狸最近想起一个英文名,于是他在网上查了很多个名字.他发现一些名字可以由两个不同的名字各取一部分得来,例如John(约翰)的前缀 "John"和Robinson(鲁滨逊)的后缀 "son" 连在一起就是Johnson. 现在他找到了两个喜欢的名字(名字可看作字符串),用A和B表示,他想知道取A的一个非空前缀和B的一个非空后缀,连接在一起能组成多少不同的字符串. 输入格式 输入两行,分别表示字符串A和B:字符串只包含小写英文字母. 输出格

hdu 4464 水

http://acm.hdu.edu.cn/showproblem.php?pid=4464 现场赛总会有水题,这就是最水的一道,估计也就是能当高校的上机题,保研用,呵呵~~~ #include <cstdio> #include <cstring> #include <iostream> using namespace std; #define ll long long const int MAXN= 100+20; char s[MAXN]; int main()

hpu 1695 一道签到题

一道签到题 时间限制: 2 Sec  内存限制: 128 MB 提交: 69  解决: 33 [提交][状态][讨论版] 题目描述 我想说这是一道签到题,意思就是本次测试中最水的一道,不过我这样说你真的愿意相信我吗?哈哈,题目是这样的给你一下小数,然后请告诉我分别告诉我这个小数的循环节的循环次数.循环节以及循环节长度 输入 输入包括多组测试数据每组测试数据1行,包括一个小数,小数的长度不超过200,小数大于0小于100 输出 分别输出这个小数的循环节的长度.循环节以及循环次数,中间以一个空格间隔

NJUST 1920 偷吃糖果【水】

偷吃糖果 Time Limit: 1000Ms Memory Limit: 65536KB [显示标签] Description 小鱼喜欢吃糖果.他有两盒糖果,两盒糖果分别仅由小写字母组成的字符串s和字符串t构成.其中'a'到'z'表示具体的某种糖果类别.他原本打算送给他喜欢的女生,但是要送给女孩子的话两盒糖果不能有差别(即字符串s和t完全相同).所以,他决定偷吃几块,他吃糖果的策略是每次选出一盒糖果中两个连续的同种类别的糖果,然后吃掉其中一块.该策略可以使用多次.例如一盒糖果是'rrrjj',

nyist oj 540 奇怪的排序(水题)

奇怪的排序 时间限制:1000 ms  |  内存限制:65535 KB 难度:1 描述 最近,Dr. Kong 新设计一个机器人Bill.这台机器人很聪明,会做许多事情.惟独对自然数的理解与人类不一样,它是从右往左读数.比如,它看到123时,会理解成321.让它比较23与15哪一个大,它说15大.原因是它的大脑会以为是32与51在进行比较.再比如让它比较29与30,它说29大. 给定Bill两个自然数A和B,让它将 [A,B] 区间中的所有数按从小到大排序出来.你会认为它如何排序? 输入 第一