CSES - HIIT Open 2018 - Results
Submission details
Task:HIIT Generation
Sender:DROP TABLE
Submission time:2018-05-26 14:11:50
Language:Java
Status:READY
Result:
Test results
testverdicttime
#1--details
#2--details
#3--details
#4ACCEPTED0.25 sdetails

Code

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		StringBuilder r = new StringBuilder();
		int limit = scanner.nextInt();
		r.append("HIIT");
		for (int i = 0; i < limit; i++) {
			char c = scanner.next().charAt(0);
			for(int j = 0; j < r.length(); j++){
				if(r.charAt(j) == c) {
					r.deleteCharAt(j);
					r.insert(j, "HIIT");
					//System.out.println("INSERTED");
					//System.out.println(r.toString());
					j += 3;
				}
			}
		}
		scanner.close();
		System.out.println(r.toString());
		/*LinkedList<Character> chars = new LinkedList<>();
		chars.add('H'); chars.add('I'); chars.add('I'); chars.add('T');
		String HIIT = HIIT2;
		Scanner scanner = new Scanner(System.in);
		
		Iterator<Character> it = chars.iterator();
		for (int i = 0; i < limit; i++) {
			Character letter = scanner.next().charAt(0);
			int index = 0;
			while(it.hasNext()){
				Character c = it.next();
				if(c.equals(letter)){
					chars.add(index, "")
				}
			}
		}
		
		for (int i = 0; i < limit; i++) {
			HIIT = HIIT.replaceAll(scanner.nextLine(), HIIT2);
		}
		System.out.println(HIIT);*/
	}
}

Test details

Test 1

Verdict:

input
17
I
I
I
I
...

correct output
HHHHHHHHHHHHHHHHHHIITHIITTHHII...

user output
(empty)

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