CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:RoniTuohino
Submission time:2017-10-05 20:40:53 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.18 sdetails
#20.18 sdetails
#3--details
#4--details
#5--details
#6--details
#7--details
#8--details
#9--details
#10--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:

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:

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:

input
ABABABABABABABABABABABABABABAB...

correct output
(empty)

user output
(empty)

Test 4

Verdict:

input
BBABABBBBBAABBBABABABBBBAAABAB...

correct output
BAB

user output
(empty)

Test 5

Verdict:

input
ACDCBBACDBBBACAACBBDBADBAABABA...

correct output
ACDCACDADBADABACACDCADADABABCA...

user output
(empty)

Test 6

Verdict:

input
EETFHIJOGACDHMGVFJCMETMZDEITTR...

correct output
TFHIJOGACDHMGVFJCMETMZDEIROTET...

user output
(empty)

Test 7

Verdict:

input
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB...

correct output
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE...

user output
(empty)

Test 8

Verdict:

input
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS...

correct output
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK...

user output
(empty)

Test 9

Verdict:

input
QUVVTPXAMWWODFXRONJODPGBTCISGM...

correct output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

user output
(empty)

Test 10

Verdict:

input
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

correct output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

user output
(empty)