CSES - HIIT Open 2018 - Results
Submission details
Task:HIIT Generation
Sender:TreamDeam
Submission time:2018-05-26 13:21:37 +0300
Language:Java
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.54 sdetails
#2--details
#3--details
#4ACCEPTED0.38 sdetails

Code

import java.util.Scanner;
public class H {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
in.nextLine();
String h = "H";
String i = "I";
String t = "T";
for (int j = 0; j < n; j++) {
String input = in.nextLine();
if (input.equals("H")) {
h = h.replaceAll("H", "HIIT");
i = i.replaceAll("H", h);
t = t.replaceAll("H", h);
} else if (input.equals("I")) {
i = i.replaceAll("I", "HIIT");
h = h.replaceAll("I", i);
t = t.replaceAll("I", i);
} else if (input.equals("T")) {
t = t.replaceAll("T", "HIIT");
h = h.replaceAll("T", t);
i = i.replaceAll("T", t);
}
}
System.out.println(h + i + i + t);
in.close();
}
}

Test details

Test 1

Verdict: ACCEPTED

input
17
I
I
I
I
...

correct output
HHHHHHHHHHHHHHHHHHIITHIITTHHII...

user output
HHHHHHHHHHHHHHHHHHIITHIITTHHII...

Test 2

Verdict:

input
333332
H
H
H
H
...

correct output
HIITIITIITIITIITIITIITIITIITII...

user output
(empty)

Test 3

Verdict:

input
24
H
T
H
T
...

correct output
HIIHIITIIHIIHIITIIHIITIIHIIHII...

user output
(empty)

Test 4

Verdict: ACCEPTED

input
0

correct output
HIIT

user output
HIIT