Burger Stand (UVA 13048) by aizu_e
Contest: 3738    RunID: 20173837    Status: Accepted    Date: Sat Oct 14 14:35:37 JST 2017


#include <bits/stdc++.h>
using namespace std;

int main() {
  int T;
  cin >> T;  
  for ( int id = 1; id <= T; id++ ) {    
    string s;
    bool ok[100];
    memset(ok, 1, sizeof(ok));
    cin >> s;
    for ( int j = 0; j < (int)s.size(); j++ ) {
      if ( s[j] == 'B' ) {
	ok[j] = ok[max(0, j-1)] = ok[max(0, j-2)] = false;
      } else if ( s[j] == 'S' ) {
	ok[j] = ok[max(0, j-1)] = ok[min((int)s.size()-1, j+1)] = false;
      } else if ( s[j] == 'D' ) {
	ok[j] = false;
      }
    }

    int ans = 0;
    for ( int i = 0; i < (int)s.size(); i++ ) if ( ok[i] ) ans++;
    cout << "Case " << id << ": "; 
    cout << ans << endl;
  }

  return 0;
}