CSES - HIIT Open 2016 - Results
Submission details
Task:HIIT remains
Sender:Verto
Submission time:2016-05-28 12:43:17 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.06 sdetails
#30.14 sdetails
#40.15 sdetails

Code

#include <iostream>
#include <cstring>

using namespace std;

int main() {
	int t;
	cin >> t;
	const char target[] = "HIIT";
	long long int arr[10000*4];
	for (int tt = 0; tt < t; tt++) {
		string s;
		cin >> s;
		memset(arr, 0, 10000*4);
		if (s[0] == target[0])
			arr[0] = 1;
		for (int i = 1; i < (int)s.size(); i++) {
			for (int j = 0; j < 4; j++) {
				arr[i*4+j] = arr[(i-1)*4+j];
			}
			for (int j = 0; j < 4; j++) {
				if (s[i] != target[j])
					continue;
				if (j == 0) {
					arr[i*4+j] += 1;
				} else {
					arr[i*4+j] += arr[(i-1)*4+j-1];
				}
			}
		}
		cout << arr[(s.size()-1)*4+3] << endl;
	}
}

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
(empty)

Test 4

Verdict:

input
3
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...

correct output
781234375000000000
4999750003
0

user output
(empty)