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:08:51
Task:HIIT remains
Sender:Team Purkka
Submission time:2016-05-28 11:08:51
Status:READY
Result:ACCEPTED

Show test data

Code

#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main () {
  int t;
  cin>>t;
  for (int i = 0; i < t; i++) {
    string s;
    cin>>s;
    ll h, i1, i2, t;
    h = i1 = i2 = t = 0;
    for (char c : s) {
      if (c == 'H') h++;
      else if (c == 'I') i2 += i1, i1 += h;
      else if (c == 'T') t += i2;
    }
    cout<<t<<endl;
  }
}