CSES - HIIT Open 2016 - Results
Submission details
Task:HIIT remains
Sender:Barely Div 1
Submission time:2016-05-28 11:37:40 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.06 sdetails
#30.09 sdetails
#40.05 sdetails

Code

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

using namespace std;

void solve(){
  string s; cin >> s;
  int n = s.size();
  vector<int> dp(4);
  for(int 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(){
  int t; cin >> t;
  while(t--) solve();
}

Test details

Test 1

Verdict: ACCEPTED

input
100
IIITIIIHITHTHIIITIII
HIHIIIIIIHIIITHIIIII
ITTIIIITIIIIIIITIIIT
IITHITITIHHIITTTIIII
...

correct output
12
84
0
37
96
...

user output
12
84
0
37
96
...

Test 2

Verdict: ACCEPTED

input
100
TIIHHITTITITIHTHIIIITHIHHIIHTI...

correct output
606723862
621369559
655243897
550750615
717769300
...

user output
606723862
621369559
655243897
550750615
717769300
...

Test 3

Verdict:

input
10
TTHTHHTIIIIIITHIIHIITITTITTIIH...

correct output
64668032062669502
66159978956790306
65755072918424640
64408596558953628
65238005187079543
...

user output
-2023013698
2081495586
-210006976
-27214692
-1123553929
...

Test 4

Verdict:

input
3
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...

correct output
781234375000000000
4999750003
0

user output
1613956608
704782707
0