A. King of Thieves
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/526/problem/A
Description
In this problem you will meet the simplified model of game King of Thieves.
In a new ZeptoLab game called "King of Thieves" your aim is to reach a chest with gold by controlling your character, avoiding traps and obstacles on your way.
An interesting feature of the game is that you can design your own levels that will be available to other players. Let‘s consider the following simple design of a level.
A dungeon consists of n segments located at a same vertical level, each segment is either a platform that character can stand on, or a pit with a trap that makes player lose if he falls into it. All segments have the same length, platforms on the scheme of the level are represented as ‘*‘ and pits are represented as ‘.‘.
One of things that affects speedrun characteristics of the level is a possibility to perform a series of consecutive jumps of the same length. More formally, when the character is on the platform number i1, he can make a sequence of jumps through the platforms i1 < i2 < ... < ik, if i2 - i1 = i3 - i2 = ... = ik - ik - 1. Of course, all segments i1, i2, ... ik should be exactly the platforms, not pits.
Let‘s call a level to be good if you can perform a sequence of four jumps of the same length or in the other words there must be a sequence i1, i2, ..., i5, consisting of five platforms so that the intervals between consecutive platforms are of the same length. Given the scheme of the level, check if it is good.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of segments on the level.
Next line contains the scheme of the level represented as a string of n characters ‘*‘ and ‘.‘.
Output
If the level is good, print the word "yes" (without the quotes), otherwise print the word "no" (without the quotes).
Sample Input
16.**.*..*.***.**.
Sample Output
yes
HINT
题意
让你选个起点,然后跳四下长度一样的,问你能否都跳到*上
题解:
啊,直接暴力就行了
代码:
//qscqesze #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 200001 #define mod 10007 #define eps 1e-9 //const int inf=0x7fffffff; //无限大 const int inf=0x3f3f3f3f; /* inline ll read() { int x=0,f=1;char ch=getchar(); while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();} return x*f; } int buf[10]; inline void write(int i) { int p = 0;if(i == 0) p++; else while(i) {buf[p++] = i % 10;i /= 10;} for(int j = p-1; j >=0; j--) putchar(‘0‘ + buf[j]); printf("\n"); } */ //************************************************************************************** char s[1000]; int main() { int n;cin>>n; scanf("%s",s+1); int flag=0; for(int i=0;i<=n;i++) { for(int j=1;j<=100;j++) { if(s[i]==‘*‘&&s[i+j]==‘*‘&&s[i+2*j]==‘*‘&&s[i+3*j]==‘*‘&&s[i+4*j]==‘*‘) { cout<<"yes"<<endl; return 0; } } } cout<<"no"<<endl; }