题意:
字符串,询问最近两个字符
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main (void) {
ios::sync_with_stdio(false);
int T; cin>>T;
int kase = 0;
while(T --) {
string s;
cin>>s;
int minn = 1005;
for(int i=0; i<s.length(); ++i) {
for(int j=i+1; j<s.length(); ++j) {
if(s[i] == s[j]) {
minn = min(minn, j-i);
}
}
}
cout<<"Case #"<<++kase<<": "<<((minn==1005)?-1:minn)<<endl;
}
return 0;
}