Code Submission Evaluation System Login

CSES - HIIT Open 2018

HIIT Open 2018

Contest start:2018-05-26 11:00:00
Contest end:2018-05-26 16:00:00

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


History
2018-05-26 14:13:27
2018-05-26 14:11:50
2018-05-26 12:19:05
2018-05-26 12:18:13
2018-05-26 12:17:00
2018-05-26 11:57:51
Task:HIIT Generation
Sender:DROP TABLE
Submission time:2018-05-26 14:13:27
Status:READY
Result:TIME LIMIT EXCEEDED

Show test data

Code

import java.util.Scanner;

public class Main {
	private static final String HIIT = "HIIT";

	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);*/
	}
}