Code Submission Evaluation System Login

CSES - HIIT Open 2016

HIIT Open 2016

Contest start:2016-05-28 11:00:00
Contest end:2016-05-28 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2016-05-28 11:50:06
Task:HIIT remains
Sender:Oispa Kaljaa
Submission time:2016-05-28 11:50:06
Status:READY
Result:ACCEPTED

Show test data

Code

#include <bits/stdc++.h>

using namespace std;

int main(){
  cin.sync_with_stdio(0);
  cin.tie(0);
  
  int tests; cin >> tests;
  while(tests--){
      string s; cin >> s;
      long long d[5] = {0};
      d[0] = 1;
      int n = s.length();
      long long ans = 0;
      for(int i = 0; i < n; i++){
	if(s[i] == 'H')
	  d[1]++;
	else if(s[i] == 'I'){
	  d[3] = d[2]+d[3];
	  d[2] += d[1];
	}
	else if(s[i] == 'T'){
	  ans+=d[3];
	}  
	
      }
      cout << ans << endl;
  }
  return 0;
}