Task: | Merkkijono |
Sender: | RoniTuohino |
Submission time: | 2017-10-05 20:40:53 +0300 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
test | verdict | time | |
---|---|---|---|
#1 | RUNTIME ERROR | 0.18 s | details |
#2 | RUNTIME ERROR | 0.18 s | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
#4 | TIME LIMIT EXCEEDED | -- | details |
#5 | TIME LIMIT EXCEEDED | -- | details |
#6 | TIME LIMIT EXCEEDED | -- | details |
#7 | TIME LIMIT EXCEEDED | -- | details |
#8 | TIME LIMIT EXCEEDED | -- | details |
#9 | TIME LIMIT EXCEEDED | -- | details |
#10 | TIME LIMIT EXCEEDED | -- | details |
Code
import java.util.*; public class Main { public static String line; public static char[] lineArray; public static void main(String[] args) { Scanner s = new Scanner(System.in); while(true){ line = s.nextLine(); lineArray = line.toCharArray(); CheckChars(); System.out.println(line); } } public static void CheckChars(){ for (int i = 0; i < line.length(); i++) { try { if (lineArray[i] == lineArray[i + 1]) //There are 2 or more letters next to eachother { int x = 0; for (int o = i; o < line.length(); o++) //Delete as many letters as there are next to eachother { if (lineArray[o] != lineArray[i]) { break; } x += 1; } //Console.WriteLine(x); line = line.replace(line.substring(i,x), ""); break; } } catch (IndexOutOfBoundsException out) { break; } } CheckLine(); } public static void CheckLine() //Check if there are any chars left to remove { lineArray = line.toCharArray(); for(int i = 0; i < lineArray.length; i++) { try { if (lineArray[i] == lineArray[i + 1]) { CheckChars(); } } catch(IndexOutOfBoundsException out) { break; } } } }
Test details
Test 1
Verdict: RUNTIME ERROR
input |
---|
ABABABABABABABABABABABABABABAB... |
correct output |
---|
ABABABABABABABABABABABABABABAB... |
user output |
---|
ABABABABABABABABABABABABABABAB... |
Error:
Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1540) at Main.main(Main.java:10)
Test 2
Verdict: RUNTIME ERROR
input |
---|
AABBAABBAABBAABBAABBAABBAABBAA... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1540) at Main.main(Main.java:10)
Test 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
ABABABABABABABABABABABABABABAB... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Test 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
BBABABBBBBAABBBABABABBBBAAABAB... |
correct output |
---|
BAB |
user output |
---|
(empty) |
Test 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
ACDCBBACDBBBACAACBBDBADBAABABA... |
correct output |
---|
ACDCACDADBADABACACDCADADABABCA... |
user output |
---|
(empty) |
Test 6
Verdict: TIME LIMIT EXCEEDED
input |
---|
EETFHIJOGACDHMGVFJCMETMZDEITTR... |
correct output |
---|
TFHIJOGACDHMGVFJCMETMZDEIROTET... |
user output |
---|
(empty) |
Test 7
Verdict: TIME LIMIT EXCEEDED
input |
---|
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB... |
correct output |
---|
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE... |
user output |
---|
(empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
input |
---|
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS... |
correct output |
---|
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK... |
user output |
---|
(empty) |
Test 9
Verdict: TIME LIMIT EXCEEDED
input |
---|
QUVVTPXAMWWODFXRONJODPGBTCISGM... |
correct output |
---|
QUTPXAMODFXRONJODPGBTCISGMVRBW... |
user output |
---|
(empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
input |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
correct output |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
user output |
---|
(empty) |