Task: | HIIT remains |
Sender: | Verto |
Submission time: | 2016-05-28 14:30:11 +0300 |
Language: | Java |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.15 s | details |
#2 | ACCEPTED | 0.29 s | details |
#3 | ACCEPTED | 0.41 s | details |
#4 | ACCEPTED | 0.35 s | details |
Code
import java.util.Vector; import java.util.Scanner; import java.util.ArrayList; import java.util.List; class H { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); String target = "HIIT"; for (int tt = 0; tt < t; tt++) { String s = sc.next(); long[] sli = new long[4]; long[] prev = new long[4]; for (int i = 0; i < s.length(); i++) { char a = s.charAt(i); for (int j = 0; j < target.length(); j++) { sli[j] = prev[j]; } for (int j = 0; j < target.length(); j++) { char b = target.charAt(j); if (a != b) continue; if (j == 0) sli[j] += 1; else sli[j] += prev[j-1]; } for (int j = 0; j < target.length(); j++) { prev[j] = sli[j]; } } System.out.println(prev[prev.length-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: ACCEPTED
input |
---|
10 TTHTHHTIIIIIITHIIHIITITTITTIIH... |
correct output |
---|
64668032062669502 66159978956790306 65755072918424640 64408596558953628 65238005187079543 ... |
user output |
---|
64668032062669502 66159978956790306 65755072918424640 64408596558953628 65238005187079543 ... |
Test 4
Verdict: ACCEPTED
input |
---|
3 HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH... |
correct output |
---|
781234375000000000 4999750003 0 |
user output |
---|
781234375000000000 4999750003 0 |