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 1414. Astronomical Database

compilation error on java
Posted by bl1n 15 Dec 2007 19:12
why I got Compilation Error ,when writing it in Java.Here is my code

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

public class Main{
    static List<Integer> a[];
    static List<Integer> w[];
    static int metka[];
    static int cnt = 0;
    private static void builtbor(String s, int x){
        if (s.length()==0){
            metka[x] = 666;
            return;
        }
        char ch = s.charAt(0);
        for (int i = 0;i<a[x].size();i++)
            if (w[x].get(i) == (int)ch){
                builtbor(s.substring(1, s.length()),a[x].get(i));
                return;
            }
        cnt++;
        a[x].add(cnt);
        w[x].add((int)ch);
        builtbor(s.substring(1, s.length()),cnt);

    }

    private static char getchar(int x){
        return (char)x;
    }

    private static void getwords(String s, int x, String now){
        if (metka[x] == 666)
            System.out.println("  "+now);
        if (!s.isEmpty()){
        char ch = s.charAt(0);
        for (int i = 0;i<a[x].size();i++)
            if (w[x].get(i) == ch)
                getwords(s.substring(1,s.length()),a[x].get(i),now+ch);
        }
        else
        {
            for (int i = 0;i<a[x].size();i++)
                    getwords(s,a[x].get(i),now+getchar(w[x].get(i)));
        }

    }
    public static void main(String[] args) throws IOException{
        Scanner in = new Scanner(System.in);
        a = new List[2000];
        w = new List[2000];
        metka = new int[20000];
        for (int i = 0;i<2000;i++)
        {
            a[i] = new ArrayList<Integer>();
            w[i] = new ArrayList<Integer>();
        }
        while (in.hasNext()){
            String s = in.next();
            char t = s.charAt(0);
            s = s.substring(1,s.length());
            if (t=='+')
                builtbor(s,0);
            else{
                System.out.println(s);
                getwords(s,0, "");
            }
        }
    }
}