读书人

11661 - Burger Time

发布时间: 2013-09-07 14:12:45 作者: rapoo

11661 - Burger Time?


Burger Time?
Everybody knows that along the more important highways there are countless fast food restaurants. One can find easily hamburgers, hot dogs, pizzas, sandwiches ... food everywhere.

Many times the problem isn't to find a restaurant but a drugstore. After a big lunch with fast food it's normal that we need a drugstore because our stomach begins to feel pain.

Given the locations of the restaurants and drugstores on a highway, you want to determine the minimum distance between a restaurant and a drugstore.

Input

The first line of each test case gives an integer L 11661 - Burger Time 2000000) indicating the length of the highway.

The second line of each test case contains a string #include<cstdio>#include<algorithm>using namespace std;char a[2000005];int main(){int n,i,j;while(scanf("%d",&n)&&n){int mind=2000005,j=0;scanf("%s",a);for(i=0;i<n;i++){if(a[i]=='Z') mind=0;if(a[i]!='.'){if(a[j]!='.'&&a[i]!=a[j])mind=min(mind,i-j);j=i;}}printf("%d\n",mind);}return 0;}

读书人网 >编程

热点推荐