CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:RoniTuohino
Submission time:2017-10-05 21:51:24 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.22 sdetails
#2ACCEPTED0.16 sdetails
#3ACCEPTED0.35 sdetails
#40.22 sdetails
#50.18 sdetails
#60.18 sdetails
#70.17 sdetails
#80.18 sdetails
#90.17 sdetails
#100.17 sdetails

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:

input
BBABABBBBBAABBBABABABBBBAAABAB...

correct output
BAB

user output
BAB
BAB
BAB
BAB
BAB
...

Test 5

Verdict:

input
ACDCBBACDBBBACAACBBDBADBAABABA...

correct output
ACDCACDADBADABACACDCADADABABCA...

user output
ACDCACDBADBADABACACDCADADABABC...

Test 6

Verdict:

input
EETFHIJOGACDHMGVFJCMETMZDEITTR...

correct output
TFHIJOGACDHMGVFJCMETMZDEIROTET...

user output
TFHIJOGACDHMGVFJCMETMZDEIROTET...

Test 7

Verdict:

input
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB...

correct output
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE...

user output
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE...

Test 8

Verdict:

input
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS...

correct output
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK...

user output
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK...

Test 9

Verdict:

input
QUVVTPXAMWWODFXRONJODPGBTCISGM...

correct output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

user output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

Test 10

Verdict:

input
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

correct output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

user output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...