CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:10GOTO10
Submission time:2017-10-03 20:18:19 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/merkkijono.java:5: error: class Main is public, should be declared in a file named Main.java
public class Main
       ^
1 error

Code

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    static int length;
    static boolean del = false;
    static boolean done = false;
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();
        StringBuilder builder = new StringBuilder(input);
        while(!done){
            done = true;
            for(int i = 0; i < builder.length()-1; i++) {
                while(i+1<builder.length() && builder.charAt(i)==builder.charAt(i+1)){
                    builder.deleteCharAt(i+1);
                    del = true;
                    done = false;
                }
                if(del){
                    builder.deleteCharAt(i);
                    del = false;
                }
            }
        }
        System.out.println(builder.toString());
    }
}