| Task: | HIIT Generation |
| Sender: | DROP TABLE |
| Submission time: | 2018-05-26 14:13:27 +0300 |
| Language: | Java |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | details |
| #2 | TIME LIMIT EXCEEDED | -- | details |
| #3 | TIME LIMIT EXCEEDED | -- | details |
| #4 | ACCEPTED | 0.23 s | details |
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);*/
}
}
Test details
Test 1
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 17 I I I I ... |
| correct output |
|---|
| HHHHHHHHHHHHHHHHHHIITHIITTHHII... |
| user output |
|---|
| (empty) |
Test 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 333332 H H H H ... |
| correct output |
|---|
| HIITIITIITIITIITIITIITIITIITII... |
| user output |
|---|
| (empty) |
Test 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 24 H T H T ... |
| correct output |
|---|
| HIIHIITIIHIIHIITIIHIITIIHIIHII... |
| user output |
|---|
| (empty) |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 0 |
| correct output |
|---|
| HIIT |
| user output |
|---|
| HIIT |
