Submission #1247412


Source Code Expand

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		String[]s =new String[h];
		for(int i=0;i<h;i++)s[i]=sc.next();
		char[][] map=new char[h+2][w+2];
		char[][] map_before=new char[h+2][w+2];
		char[][] map_after=new char[h+2][w+2];
		
		for(int i=0;i<h+2;i++){
			for(int j=0;j<w+2;j++){
				if(i==0 || i==h+1 || j==0 || j==w+1)map[i][j]='.';
				else {
					map_before[i][j]=map[i][j]=s[i-1].charAt(j-1);
				}
				
			}
		}
		//白いところの周りはもともと白
		for(int i=1;i<h+1;i++){
			for(int j=1;j<w+1;j++){
				if(map[i][j]=='.'){
					for(int k=-1;k<=1;k++){
						for(int l=-1;l<=1;l++){
							map_before[i+k][j+l]='.';
						}
					}
				}
				map_after[i][j]='.';
			}
		}
		//戻した画像を再び収縮
		for(int i=1;i<h+1;i++){
			for(int j=1;j<w+1;j++){
				for(int k=-1;k<=1;k++){
					for(int l=-1;l<=1;l++){
						if(map_before[i+k][j+l]=='#')map_after[i][j]='#';
					}
				}
			}
		}
		for(int i=1;i<h+1;i++){
			for(int j=1;j<w+1;j++){
				if(map[i][j]!=map_after[i][j]){
					System.out.println("impossible");
					return;
				}
			}
		}
		System.out.println("possible");
	}

}

Submission Info

Submission Time
Task D - 画像処理高橋君
User kwkm0429
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 1297 Byte
Status WA
Exec Time 117 ms
Memory 22868 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 1
WA × 2
AC × 11
WA × 14
Set Name Test Cases
Sample example_0.txt, example_1.txt, example_2.txt
All example_0.txt, example_1.txt, example_2.txt, handmade_0.txt, handmade_1.txt, possible_0.txt, possible_1.txt, possible_2.txt, possible_3.txt, possible_4.txt, possible_5.txt, possible_6.txt, possible_7.txt, possible_8.txt, possible_9.txt, random_0.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt
Case Name Status Exec Time Memory
example_0.txt WA 92 ms 21844 KB
example_1.txt WA 93 ms 22612 KB
example_2.txt AC 92 ms 19924 KB
handmade_0.txt WA 93 ms 18644 KB
handmade_1.txt WA 91 ms 18900 KB
possible_0.txt WA 102 ms 19156 KB
possible_1.txt WA 117 ms 21844 KB
possible_2.txt WA 111 ms 20816 KB
possible_3.txt WA 113 ms 18900 KB
possible_4.txt WA 100 ms 17492 KB
possible_5.txt WA 106 ms 21844 KB
possible_6.txt WA 111 ms 21972 KB
possible_7.txt WA 115 ms 21844 KB
possible_8.txt WA 104 ms 20948 KB
possible_9.txt WA 111 ms 21844 KB
random_0.txt AC 95 ms 19924 KB
random_1.txt AC 105 ms 19412 KB
random_2.txt AC 94 ms 21460 KB
random_3.txt AC 97 ms 18772 KB
random_4.txt AC 93 ms 19924 KB
random_5.txt AC 111 ms 20180 KB
random_6.txt AC 113 ms 20180 KB
random_7.txt AC 111 ms 19024 KB
random_8.txt AC 96 ms 21844 KB
random_9.txt AC 115 ms 22868 KB