Task: | Merkkijono |
Sender: | RoniTuohino |
Submission time: | 2017-10-05 22:05:09 +0300 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.22 s | details |
#2 | ACCEPTED | 0.19 s | details |
#3 | ACCEPTED | 0.20 s | details |
#4 | WRONG ANSWER | 0.15 s | details |
#5 | WRONG ANSWER | 0.16 s | details |
#6 | WRONG ANSWER | 0.18 s | details |
#7 | WRONG ANSWER | 0.18 s | details |
#8 | WRONG ANSWER | 0.21 s | details |
#9 | WRONG ANSWER | 0.20 s | details |
#10 | WRONG ANSWER | 0.18 s | 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); 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; } //System.out.println(i); //System.out.println(x); for(int p = 0; p < x; p++){ line = line.replace(line.substring(i,i+1), ""); 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]) { //System.out.println(lineArray); CheckChars(); } } catch(IndexOutOfBoundsException out) { break; } } } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABABABABABABABABABABABABABABAB... |
correct output |
---|
ABABABABABABABABABABABABABABAB... |
user output |
---|
ABABABABABABABABABABABABABABAB... |
Test 2
Verdict: ACCEPTED
input |
---|
AABBAABBAABBAABBAABBAABBAABBAA... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Test 3
Verdict: ACCEPTED
input |
---|
ABABABABABABABABABABABABABABAB... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Test 4
Verdict: WRONG ANSWER
input |
---|
BBABABBBBBAABBBABABABBBBAAABAB... |
correct output |
---|
BAB |
user output |
---|
(empty) |
Test 5
Verdict: WRONG ANSWER
input |
---|
ACDCBBACDBBBACAACBBDBADBAABABA... |
correct output |
---|
ACDCACDADBADABACACDCADADABABCA... |
user output |
---|
(empty) |
Test 6
Verdict: WRONG ANSWER
input |
---|
EETFHIJOGACDHMGVFJCMETMZDEITTR... |
correct output |
---|
TFHIJOGACDHMGVFJCMETMZDEIROTET... |
user output |
---|
(empty) |
Test 7
Verdict: WRONG ANSWER
input |
---|
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB... |
correct output |
---|
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE... |
user output |
---|
(empty) |
Test 8
Verdict: WRONG ANSWER
input |
---|
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS... |
correct output |
---|
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK... |
user output |
---|
(empty) |
Test 9
Verdict: WRONG ANSWER
input |
---|
QUVVTPXAMWWODFXRONJODPGBTCISGM... |
correct output |
---|
QUTPXAMODFXRONJODPGBTCISGMVRBW... |
user output |
---|
(empty) |
Test 10
Verdict: WRONG ANSWER
input |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
correct output |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
user output |
---|
(empty) |