SPOJ 10234. 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!
#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的更多相关文章
- 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 ... 
- SPOJ DQUERY D-query(主席树)
		题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ... 
- 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 ... 
- 【填坑向】spoj COT/bzoj2588 Count on a tree
		这题是学主席树的时候就想写的,,, 但是当时没写(懒) 现在来填坑 = =日常调半天lca(考虑以后背板) 主席树还是蛮好写的,但是代码出现重复,不太好,导致调试的时候心里没底(虽然事实证明主席树部分 ... 
- SPOJ bsubstr
		题目大意:给你一个长度为n的字符串,求出所有不同长度的字符串出现的最大次数. n<=250000 如:abaaa 输出: 4 2 1 1 1 spoj上的时限卡的太严,必须使用O(N)的算法那才 ... 
- 【SPOJ 7258】Lexicographical Substring Search
		http://www.spoj.com/problems/SUBLEX/ 好难啊. 建出后缀自动机,然后在后缀自动机的每个状态上记录通过这个状态能走到的不同子串的数量.该状态能走到的所有状态的f值的和 ... 
- 【SPOJ 1812】Longest Common Substring II
		http://www.spoj.com/problems/LCS2/ 这道题想了好久. 做法是对第一个串建后缀自动机,然后用后面的串去匹配它,并在走过的状态上记录走到这个状态时的最长距离.每匹配完一个 ... 
- 【SPOJ 8222】Substrings
		http://www.spoj.com/problems/NSUBSTR/ clj课件里的例题 用结构体+指针写完模板后发现要访问所有的节点,改成数组会更方便些..于是改成了数组... 这道题重点是求 ... 
- SPOJ GSS2 Can you answer these queries II
		Time Limit: 1000MS Memory Limit: 1572864KB 64bit IO Format: %lld & %llu Description Being a ... 
随机推荐
- .net HttpCrawler
			using HtmlAgilityPack; using System; using System.Collections.Generic; using System.Diagnostics; usi ... 
- textarea保留换行和空格
			<style> pre {white-space: pre-wrap;} </style> //替换textare <pre class="feedback_q ... 
- 【转】GridView 加载空行并点击编辑每一个单元格
			代码 <script runat="server"> protectedvoid Button1_Click(object sender, System.EventAr ... 
- c++ 类的构造顺序
			在单继承的情况下,父类构造先于子类,子类析构先于父类,例: class A { public: A() { cout << "A" << endl; } ~ ... 
- C基础 旋转数组查找题目
			前言 - 引言 题目: 一类有序数组旋转查值问题. 例如: 有序数组 [ , , , , , , , , ] 旋转后为 [ , , , , , , , , ] 如何从中找出一个值索引, not fou ... 
- cobbler 无人值守系统安装
			概述 本文适合centos6 | centos7 系统的安装 执行操作之前:检查系统防火墙,selinux是否关闭,网络链接是否畅通. Cobbler是一个免费开源系统安装部署软件,用于自动化网络安装 ... 
- 关于vc++ 6.0 编译器,点打开文件时自动关闭
			装好VC++ 6.0后,点打开文件时编译器会自动关闭掉,然后在网上找到各位大神写的资料,果然是因为之前有安装vs2010冲突的缘故,然后http://download.csdn.net/source/ ... 
- irport报表,把数字金额转换成大写人民币金额
			1.编写oracle函数 CREATE OR REPLACE Function MoneyToChinese(Money In Number) Return Varchar2 Is strYuan ) ... 
- 洛谷P1782 旅行商的背包
			传送门啦 这个题不用二进制优化的话根本不行,现学的二进制优化,调了一段时间终于A了,不容易.. 如果不懂二进制优化的话可以去看我那个博客 二进制优化多重背包入口 不想TLE,不要打memset,一定要 ... 
- HDU 1068  Girls and Boys(最大独立集)
			题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 题目大意:有n个人,一些人认识另外一些人,选取一个集合,使得集合里的每个人都互相不认识,求该集合 ... 
