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 1769. Old Ural Legend

Why Crash#6, Help me please!
Posted by Enigma [UB of TUIT] 24 Oct 2011 19:28
package Oct_24;
import java.io.IOException;
import java.io.InputStreamReader;

public class T_1769 {
    public static void main(String[] args) throws IOException {
        InputStreamReader is = new InputStreamReader(System.in);
            char c[] = new char[(int) 4e+5 + 1];
            int k = 0;
            c[k] = (char)is.read();
            while(is.ready()){
                k++;
                c[k] = (char) is.read();
            }
            k--;
            int t = 0;
            int [] a = new int [100001];
            for (int i = 1; i <=4; i++) {
                for (int j = 0; j+i <= k; j++) {
                    String s = (new String(c,j,i));
                    a[t] = Integer.parseInt(s);
                    t++;
                }
            }
            boolean f[] = new boolean [400001];
            for (int i = 0; i < t; i++) {
                f[a[i]]= true;
            }
            for (int i = 1; i < f.length; i++) {
                if(!f[i]){
                    System.out.println(i);
                    return;
                }
            }
    }
}

Edited by author 24.10.2011 19:29

Edited by author 24.10.2011 19:29