Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.bakes;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.util.Arrays;
- public class A {
- public static void main(String[] args) {
- A park = new A();
- park.calculate();
- }
- private void calculate() {
- BufferedReader in;
- String strLine1;
- String strLine2;
- String strLine3;
- PrintWriter out;
- try {
- in = new BufferedReader(new FileReader("input.in"));
- in.readLine();
- FileWriter outFile = new FileWriter("output.txt");
- out = new PrintWriter(outFile);
- int n = 0;
- while ((strLine1 = in.readLine()) != null) {
- n++;
- String[] data = strLine1.split(" ");
- System.out.println(strLine1);
- int height = Integer.parseInt(data[0]);
- int width = Integer.parseInt(data[1]);
- char[][] image = new char[height][width];
- for (int i = 0; i<height; i++)
- {
- char[] line = in.readLine().toCharArray();
- for (int j = 0; j < width; j++)
- {
- image[i][j] = line[j];
- }
- }
- for (int i = 0; i<height-1; i++)
- {
- for (int j = 0; j < width-1; j++)
- {
- if ((image[i][j] == '#') && (image[i][j+1] == '#') && (image[i+1][j] == '#') && (image[i+1][j+1] == '#'))
- {
- image[i][j] = '/';
- image[i][j+1] = '\\';
- image[i+1][j] = '\\';
- image[i+1][j+1] = '/';
- }
- }
- }
- boolean done = true;
- for (int i = 0; i<height; i++)
- {
- for (int j = 0; j < width; j++)
- {
- if (image[i][j] == '#')
- {
- done = false;
- }
- }
- }
- out.println("Case #"+n+":");
- if (!done)
- {
- out.println("Impossible");
- }
- else if (true)
- {
- for (int i = 0; i<height; i++)
- {
- String s = "";
- for (int j = 0; j < width; j++)
- {
- s += image[i][j];
- }
- out.println(s);
- }
- }
- }
- out.close();
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement