Guest User

Untitled

a guest
Oct 23rd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.19 KB | None | 0 0
  1.  
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5. import java.lang.Math;
  6.  
  7. public class problem_B60 {
  8.  
  9.     final boolean text = false;
  10.  
  11.     BufferedReader in;
  12.     PrintWriter out;
  13.     StringTokenizer tok = new StringTokenizer("");
  14.  
  15.     void init() throws IOException {
  16.         if (text) {
  17.             in = new BufferedReader(new InputStreamReader(System.in));
  18.             out = new PrintWriter(System.out);
  19.         } else {
  20.             in = new BufferedReader(new FileReader("input.txt"));
  21.             out = new PrintWriter("output.txt");
  22.         }
  23.     }
  24.  
  25.     String readString() throws IOException {
  26.         while (!tok.hasMoreTokens()) {
  27.             tok = new StringTokenizer(in.readLine());
  28.         }
  29.         return tok.nextToken();
  30.     }
  31.  
  32.     int readInt() throws IOException {
  33.         return Integer.parseInt(readString());
  34.     }
  35.  
  36.     long readLong() throws IOException {
  37.         return Long.parseLong(readString());
  38.     }
  39.  
  40.     double readDouble() throws IOException {
  41.         return Double.parseDouble(readString());
  42.     }
  43.    
  44.     void debug(Object o) {
  45.         System.err.println(o.toString());
  46.     }
  47.    
  48.     void run() {
  49.         try {
  50.             long t1 = System.currentTimeMillis();
  51.             init();
  52.             solve();
  53.             out.close();
  54.             long t2 = System.currentTimeMillis();
  55.             debug("Time = " + (t2 - t1));
  56.         } catch (Exception e) {
  57.             throw new RuntimeException(e);
  58.         }
  59.     }
  60.  
  61.     public static void main(String[] args) {
  62.         (new problem_B60()).run();
  63.     }
  64.    
  65.     void paint(int x, int y, int z) {
  66.         if (a[x][y][z]<0) {
  67.             return;
  68.         } else {
  69.             a[x][y][z]=3;
  70.             paint(x+1,y,z);
  71.             paint(x,y+1,z);
  72.             paint(x,y,z+1);
  73.             paint(x-1,y,z);
  74.             paint(x,y-1,z);
  75.             paint(x,y,z-1);
  76.         }
  77.     }
  78.  
  79.     int[][][] a= new int[15][15][15];
  80.    
  81.     void solve() throws IOException {
  82.         int k=readInt(), n=readInt(), m=readInt();
  83.         for (int i=0; i<k+2; i++) for (int ii=0; ii<n+2; ii++) for (int iii=0; iii<m+2; iii++) a[i][ii][iii]=-1;
  84.         for (int i=0; i<k; i++)
  85.         {   String s;
  86.             for (int ii=0; ii<n; ii++) {
  87.                 s=readString();
  88.                 for (int iii=0; iii<m; iii++) {
  89.                         a[i+1][ii+1][iii+1]=(s.charAt(iii)=='#' ? -1:1);
  90.                    
  91.                 }
  92.             }
  93.            
  94.         }
  95.        
  96.         int x=readInt(), y=readInt();
  97.         paint(1,x,y);
  98.         int rez=0;
  99.         for (int i=1; i<k+1; i++) for (int ii=1; ii<n+1; ii++) for (int iii=1; iii<m+1; iii++)
  100.              if (a[i][ii][iii]==3) rez++;
  101.         out.println(rez);
  102.        
  103. }
  104.        
  105. }
Add Comment
Please, Sign In to add comment