11661 - Burger Time?
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.
The first line of each test case gives an integer L
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;}