Code Submission Evaluation System Login

CSES - HIIT Open 2016

HIIT Open 2016

Contest start:2016-05-28 11:00:00
Contest end:2016-05-28 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2016-05-28 14:30:11
2016-05-28 14:13:38
2016-05-28 12:43:17
2016-05-28 12:40:33
2016-05-28 12:23:10
Task:HIIT remains
Sender:Verto
Submission time:2016-05-28 14:30:11
Status:READY
Result:ACCEPTED

Show test data

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]);
		}
	}
}