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:24:36
Task:HIIT remains
Sender:Noname 01
Submission time:2016-05-28 11:24:36
Status:READY
Result:ACCEPTED

Show test data

Code

// NONAME-01

#include <bits/stdc++.h>


using namespace std;

string s;

void Load()
{
  cin >> s;
}

void Solve()
{
  int i;
  long long d1 = 0;
  long long d2 = 0;
  long long d3 = 0;
  long long d4 = 0;
  for (i = 0; i < (int)s.size(); i++) {
	if (s[i] == 'H') d1++;
	if (s[i] == 'I') {
		d3 += d2;
		d2 += d1;
	}
	if (s[i] == 'T') {
		d4 += d3;
	}
  }
  cout << d4 << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int nt, tt;
  cin >>nt;
  for (tt = 0; tt < nt; tt++) {
	Load();
	Solve();
  }
  return 0;
}