Language: Java

public class Main  implements Runnable { //Runnableを実装する

    public static void main(String[] args) {

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行

    }

    public void run() {
		FastScanner sc = new FastScanner(System.in);

		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		//int b = Integer.parseInt(sc.next());
		//int t = Integer.parseInt(sc.next());
		//int k = 0;
		//int k = Integer.parseInt(sc.next());
		//String str = sc.next();
		//char c[] = str.toCharArray();
		char a[][] = new char[h][w];
		char anext[][] = new char[h][w];
		int atmp[] = new int[h];
		int max= 0;
		int blackar[][] = new int[h*w][2];
		int whar[][] = new int[h*w][2];
		int p=0;
		int pw=0;
		for (int i = 0; i < h; i++)
		{
				a[i]= sc.next().toCharArray();
				for (char j = 0; j < w; j++)
				{
					if(a[i][j]=='#')
					{
						blackar[p][0]=i;
						blackar[p][1]=j;
						p++;
					}
					else
					{
						whar[pw][0]=i;
						whar[pw][1]=j;
						pw++;
					}
				}
		}
		//a[1][1]='#';

/*		for (char i = 0; i < h; i++)
		{
			for (char j = 0; j < w; j++)
			{
				if(a[i][j]=='#')
				{
					blackar[p][0]=i;
					blackar[p][1]=j;
					p++;
				}
				else
				{
					whar[pw][0]=i;
					whar[pw][1]=j;
					pw++;
				}
			}
		}*/
		//blackar[p][0]=-1;
		//whar[pw][0]=-1;
		int maxp = p;
		int maxpw = pw;
    	int p2=p;
		p=0;
	    while(p<h*w)
	    {
			//int blackarnext[][] = new int[h*w][2];


		    int hap = 0;
			for (; p<maxp;p++)
			{
				int i = blackar[p][0];
				int j = blackar[p][1];
				//if(a[i][j] == '.')
				//{
					if(i-1>=0)
					{
						if (a[i-1][j] == '.')
						{
							a[i-1][j] = '#';
							blackar[p2][0]=i-1;
							blackar[p2][1]=j;
							p2++;
						}
					}
					if(j-1>=0)
					{
						if (a[i][j-1] == '.')
						{
							a[i][j-1] = '#';
							blackar[p2][0]=i;
							blackar[p2][1]=j-1;
							p2++;
						}
					}
					if(i+1<h)
					{
						if (a[i+1][j] == '.')
						{
							a[i+1][j] = '#';
							blackar[p2][0]=i+1;
							blackar[p2][1]=j;
							p2++;
						}
					}
					if(j+1<w)
					{
						if (a[i][j+1] == '.')
						{
							a[i][j+1] = '#';
							blackar[p2][0]=i;
							blackar[p2][1]=j+1;
							p2++;
						}
					}
				//}

		    }
			maxp=p2;
			max++;
			//blackarnext[p2][0]=-1;
			//blackar = blackarnext;
		}
	    max= max-1;
/*		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if(a[i][j] == '.')
				{
					int localmax=2000;
					l2:for (int x = 0; x < h; x++)
					{
						for (int y = 0; y < w; y++)
						{
							if(a[x][y]=='#')
							{
								int length = Math.abs(i-x)+Math.abs(j-y);
								if(length<localmax)
								{
									localmax = length;
									if(localmax<max)
									{
										break l2;
									}
								}
							}
						}
					}
					if(max<localmax)
					{
						max = localmax;
					}
				}
			}
		}*/
/*		for (pw = 0; pw<maxpw; pw++)
		{
			int localmax=2000;
			l2:for (p = 0; p<maxp; p++)
			{
				int length = Math.abs(whar[pw][0]-blackar[p][0])+Math.abs(whar[pw][1]-blackar[p][1]);
				if(length<localmax)
				{
					localmax = length;
					if(localmax<=max)
					{
						break l2;
					}
				}
			}
			if(max<localmax)
			{
				max = localmax;
			}
		}*/
		int ans = max;

		PrintWriter out = new PrintWriter(System.out);
		out.println(ans);
		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
        
        public long nextInt() {
            return Integer.parseInt(next());
        }

    }

}


Compiler output:
Main.java:194: error: cannot find symbol
        private BufferedReader reader = null;
                ^
  symbol:   class BufferedReader
  location: class FastScanner
Main.java:195: error: cannot find symbol
        private StringTokenizer tokenizer = null;
                ^
  symbol:   class StringTokenizer
  location: class FastScanner
Main.java:201: error: cannot find symbol
        public FastScanner(InputStream in) {
                           ^
  symbol:   class InputStream
  location: class FastScanner
Main.java:188: error: cannot find symbol
		PrintWriter out = new PrintWriter(System.out);
		^
  symbol:   class PrintWriter
  location: class Main
Main.java:188: error: cannot find symbol
		PrintWriter out = new PrintWriter(System.out);
		                      ^
  symbol:   class PrintWriter
  location: class Main
Main.java:197: error: cannot find symbol
        	StringReader sr = new StringReader(in);
        	^
  symbol:   class StringReader
  location: class FastScanner
Main.java:197: error: cannot find symbol
        	StringReader sr = new StringReader(in);
        	                      ^
  symbol:   class StringReader
  location: class FastScanner
Main.java:198: error: cannot find symbol
            reader = new BufferedReader(new BufferedReader(sr));
                         ^
  symbol:   class BufferedReader
  location: class FastScanner
Main.java:198: error: cannot find symbol
            reader = new BufferedReader(new BufferedReader(sr));
                                            ^
  symbol:   class BufferedReader
  location: class FastScanner
Main.java:202: error: cannot find symbol
            reader = new BufferedReader(new InputStreamReader(in));
                         ^
  symbol:   class BufferedReader
  location: class FastScanner
Main.java:202: error: cannot find symbol
            reader = new BufferedReader(new InputStreamReader(in));
                                            ^
  symbol:   class InputStreamReader
  location: class FastScanner
Main.java:209: error: cannot find symbol
                    tokenizer = new StringTokenizer(reader.readLine());
                                    ^
  symbol:   class StringTokenizer
  location: class FastScanner
Main.java:210: error: cannot find symbol
                } catch (IOException e) {
                         ^
  symbol:   class IOException
  location: class FastScanner
Main.java:221: error: cannot find symbol
                } catch (IOException e) {
                         ^
  symbol:   class IOException
  location: class FastScanner
14 errors