Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- import java.lang.Math;
- public class problem_B60 {
- final boolean text = false;
- BufferedReader in;
- PrintWriter out;
- StringTokenizer tok = new StringTokenizer("");
- void init() throws IOException {
- if (text) {
- in = new BufferedReader(new InputStreamReader(System.in));
- out = new PrintWriter(System.out);
- } else {
- in = new BufferedReader(new FileReader("input.txt"));
- out = new PrintWriter("output.txt");
- }
- }
- String readString() throws IOException {
- while (!tok.hasMoreTokens()) {
- tok = new StringTokenizer(in.readLine());
- }
- return tok.nextToken();
- }
- int readInt() throws IOException {
- return Integer.parseInt(readString());
- }
- long readLong() throws IOException {
- return Long.parseLong(readString());
- }
- double readDouble() throws IOException {
- return Double.parseDouble(readString());
- }
- void debug(Object o) {
- System.err.println(o.toString());
- }
- void run() {
- try {
- long t1 = System.currentTimeMillis();
- init();
- solve();
- out.close();
- long t2 = System.currentTimeMillis();
- debug("Time = " + (t2 - t1));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- public static void main(String[] args) {
- (new problem_B60()).run();
- }
- void paint(int x, int y, int z) {
- if (a[x][y][z]<0) {
- return;
- } else {
- a[x][y][z]=3;
- paint(x+1,y,z);
- paint(x,y+1,z);
- paint(x,y,z+1);
- paint(x-1,y,z);
- paint(x,y-1,z);
- paint(x,y,z-1);
- }
- }
- int[][][] a= new int[15][15][15];
- void solve() throws IOException {
- int k=readInt(), n=readInt(), m=readInt();
- 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;
- for (int i=0; i<k; i++)
- { String s;
- for (int ii=0; ii<n; ii++) {
- s=readString();
- for (int iii=0; iii<m; iii++) {
- a[i+1][ii+1][iii+1]=(s.charAt(iii)=='#' ? -1:1);
- }
- }
- }
- int x=readInt(), y=readInt();
- paint(1,x,y);
- int rez=0;
- for (int i=1; i<k+1; i++) for (int ii=1; ii<n+1; ii++) for (int iii=1; iii<m+1; iii++)
- if (a[i][ii][iii]==3) rez++;
- out.println(rez);
- }
- }
Add Comment
Please, Sign In to add comment