Arrows (UVA 13047) by UKUNICHIA
Contest: 3738    RunID: 20173528    Status: Accepted    Date: Sat Oct 14 13:37:31 JST 2017


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