照題目找出最近的兩店的距離即可。
C++(0.092)
/*******************************************************/
/* UVa 11661 Burger Time */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2012/09/20 */
/*******************************************************/
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int L;
char road, state;
int position, distance;
while( scanf( "%d", &L ) != EOF && L ){
getchar();
state = '.';
position = -1;
distance = 2000001;
for( int i = 0 ; i < L ; i++ ){
road = getchar();
if( road == 'Z' ) distance = 0;
if( road != '.' ){
if( state != road && state != '.' )
if( i - position < distance ) distance = i - position;
state = road;
position = i;
}
}
printf( "%d\n", distance );
}
return 0;
}