Task: | Merkkijono |
Sender: | RoniTuohino |
Submission time: | 2017-10-05 21:51:24 +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.16 s | details |
#3 | ACCEPTED | 0.35 s | details |
#4 | WRONG ANSWER | 0.22 s | details |
#5 | WRONG ANSWER | 0.18 s | details |
#6 | WRONG ANSWER | 0.18 s | details |
#7 | WRONG ANSWER | 0.17 s | details |
#8 | WRONG ANSWER | 0.18 s | details |
#9 | WRONG ANSWER | 0.17 s | details |
#10 | WRONG ANSWER | 0.17 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(); /*for (int i = 0; i < line.length() - 1; 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]) { //System.out.println(lineArray[o]); break; } x += 1; } System.out.println(i); System.out.println(x); line = line.replace(line.substring(i,x +i), ""); } } catch (IndexOutOfBoundsException out) { break; } } System.out.println(line);*/ CheckChars(); } 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); line = line.replace(line.substring(i,x+i), ""); 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; } } Finish(); //End the program } public static void Finish(){ System.out.println(line); } }
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 |
---|
... |
Test 4
Verdict: WRONG ANSWER
input |
---|
BBABABBBBBAABBBABABABBBBAAABAB... |
correct output |
---|
BAB |
user output |
---|
BAB BAB BAB BAB BAB ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
ACDCBBACDBBBACAACBBDBADBAABABA... |
correct output |
---|
ACDCACDADBADABACACDCADADABABCA... |
user output |
---|
ACDCACDBADBADABACACDCADADABABC... |
Test 6
Verdict: WRONG ANSWER
input |
---|
EETFHIJOGACDHMGVFJCMETMZDEITTR... |
correct output |
---|
TFHIJOGACDHMGVFJCMETMZDEIROTET... |
user output |
---|
TFHIJOGACDHMGVFJCMETMZDEIROTET... |
Test 7
Verdict: WRONG ANSWER
input |
---|
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB... |
correct output |
---|
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE... |
user output |
---|
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE... |
Test 8
Verdict: WRONG ANSWER
input |
---|
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS... |
correct output |
---|
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK... |
user output |
---|
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK... |
Test 9
Verdict: WRONG ANSWER
input |
---|
QUVVTPXAMWWODFXRONJODPGBTCISGM... |
correct output |
---|
QUTPXAMODFXRONJODPGBTCISGMVRBW... |
user output |
---|
QUTPXAMODFXRONJODPGBTCISGMVRBW... |
Test 10
Verdict: WRONG ANSWER
input |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
correct output |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
user output |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |