CSES - Practice Contest 2024 - Results
Submission details
Task:HIIT remains
Sender:\(._.)/
Submission time:2024-09-28 13:16:09 +0300
Language:C++ (C++11)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.03 sdetails
#4ACCEPTED0.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int i = 0; i < s.size(); i++)
      |                         ~~^~~~~~~~~~

Code

// Online C++ compiler to run C++ program online
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int n;
    cin >> n;
    
    string s;
    
    for (int test = 0; test < n; test++)
    {
        cin >> s;
        long long h = 0;
        long long hi = 0;
        long long hii = 0;
        long long hiit = 0;
        
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] == 'H')
                h++;
            if (s[i] == 'I')
            {
                hii += hi;
                hi += h;
            }
            if (s[i] == 'T')
                hiit += hii;
        }
        
        cout << hiit << endl;
    }

    return 0;
}

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
...
Truncated

Test 2

Verdict: ACCEPTED

input
100
TIIHHITTITITIHTHIIIITHIHHIIHTI...

correct output
606723862
621369559
655243897
550750615
717769300
...

user output
606723862
621369559
655243897
550750615
717769300
...
Truncated

Test 3

Verdict: ACCEPTED

input
10
TTHTHHTIIIIIITHIIHIITITTITTIIH...

correct output
64668032062669502
66159978956790306
65755072918424640
64408596558953628
65238005187079543
...

user output
64668032062669502
66159978956790306
65755072918424640
64408596558953628
65238005187079543
...
Truncated

Test 4

Verdict: ACCEPTED

input
3
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...

correct output
781234375000000000
4999750003
0

user output
781234375000000000
4999750003
0