Arrows (UVA 13047) by aizu_e
Contest: 3738    RunID: 20173717    Status: Accepted    Date: Sat Oct 14 14:14:09 JST 2017


#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int k=1;k<=n;k++){
    int ans=0;
    string s;
    cin>>s;
    int size=s.size();
    for(int i=0;i<size;i++){
      if(s[i]=='<'){
	int t=1;
	ans=max(t,ans);
	for(int j=i+1;j<size;j++){
	  if(j==i+1&&(s[j]=='-'||s[j]=='='))t++;
	  ans=max(t,ans);
	  if(j==size-1)break;
	  if(s[j]!=s[j+1]||s[j]=='<'||s[j]=='>')break;
	  t++;
	  ans=max(t,ans);
	}
      }else if(s[i]=='>'){
	int t=1;
	ans=max(t,ans);
	for(int j=i-1;j>=0;j--){
	  if(j==i-1&&(s[j]=='-'||s[j]=='='))t++;
	  ans=max(t,ans);
	  if(j==0)break;
	  if(s[j]!=s[j-1]||s[j]=='<'||s[j]=='>')break;
	  t++;
	  ans=max(t,ans);
	}
      }
    }
    cout<<"Case "<<k<<": ";
    if(ans)cout<<ans<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}