ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1910. Titan Ruins: Hidden Entrance

Still dont see why i get "Crash"
Posted by Andrey 29 Jan 2013 21:18
Guys, i run program and it works. Why does it crash?
Could you point me to the problem in my code?

public static void main(String[] args) throws IOException {
        int sum=0;
        Scanner s = new Scanner (System.in);
        int a = s.nextInt ();

        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        String s1 = br.readLine ();


        for (int i = 0; i<a-2; i++) {
            if (s1.charAt (i)==s1.charAt (i+1) && s1.charAt (i) == s1.charAt (i+2)) {
            String s2 = Character.toString (s1.charAt (i));
            sum = Integer.parseInt (s2);
            System.out.print (sum*3 + " ");

            }
        }

        for (int i = 0; i<a-2; i++) {
            if (s1.charAt (i)==s1.charAt (i+1) && s1.charAt (i) == s1.charAt (i+2)) {

                System.out.print (s1.indexOf(s1.charAt (i))+2);

            }