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:39:49
2016-05-28 11:37:40
Task:HIIT remains
Sender:Barely Div 1
Submission time:2016-05-28 11:39:49
Status:READY
Result:ACCEPTED

Show test data

Code

#include <iostream>
#include <string>
#include <set>
#include <vector>

using namespace std;

typedef int64_t LL;

void solve(){
  string s; cin >> s;
  LL n = s.size();
  vector<LL> dp(4);
  for(LL i = 0; i < n; i++){
    if(s[i] == 'H') dp[0]++;
    if(s[i] == 'I'){
      dp[2] += dp[1];
      dp[1] += dp[0];
    }
    if(s[i] == 'T'){
      dp[3] += dp[2];
    }
  }
  cout << dp[3] << endl;
}

int main(){
  LL t; cin >> t;
  while(t--) solve();
}