CSES - Practice Contest 2024 - Results
Submission details
Task:HIIT remains
Sender:\(._.)/
Submission time:2024-09-28 13:12:59 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.01 sdetails
#30.03 sdetails
#40.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;
        int h = 0;
        int hi = 0;
        int hii = 0;
        int 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:

input
10
TTHTHHTIIIIIITHIIHIITITTITTIIH...

correct output
64668032062669502
66159978956790306
65755072918424640
64408596558953628
65238005187079543
...

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

Test 4

Verdict:

input
3
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...

correct output
781234375000000000
4999750003
0

user output
1613956608
704782707
0