CSES - HIIT Open 2016 - Results
Submission details
Task:HIIT remains
Sender:Verto
Submission time:2016-05-28 12:23:10 +0300
Language:Python2
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.35 sdetails
#3--details
#4ACCEPTED1.00 sdetails

Code

import sys
def asints(s):
	return [int(x.strip()) for x in s.split()]
def asoneint(s):
	return int(s.strip())
lines = sys.stdin.readlines()

target = "HIIT"

t = asoneint(lines[0])
for i in range(t):
	s = lines[i+1]
	arr = [[0 for y in range(len(target))] for x in range(len(s))]
	for i,a in enumerate(s):
		for j in range(len(target)):
			arr[i][j] = arr[i-1][j]
		for j in range(len(target)):
			if a == target[j]:
				if j == 0:
					arr[i][j] += 1
				else:
					arr[i][j] += arr[i-1][j-1]
	from pprint import pprint
	print arr[-1][-1]

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: ACCEPTED

input
3
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...

correct output
781234375000000000
4999750003
0

user output
781234375000000000
4999750003
0