Submission #1247416
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"); for(int i=1;i<h+1;i++){ for(int j=1;j<w+1;j++){ System.out.print(map_before[i][j]); } System.out.println(); } } }
Submission Info
Submission Time | |
---|---|
Task | D - 画像処理高橋君 |
User | kwkm0429 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 1428 Byte |
Status | AC |
Exec Time | 180 ms |
Memory | 25428 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
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 | AC | 95 ms | 18896 KB |
example_1.txt | AC | 94 ms | 23892 KB |
example_2.txt | AC | 97 ms | 19668 KB |
handmade_0.txt | AC | 95 ms | 21844 KB |
handmade_1.txt | AC | 93 ms | 19796 KB |
possible_0.txt | AC | 129 ms | 20052 KB |
possible_1.txt | AC | 148 ms | 20436 KB |
possible_2.txt | AC | 140 ms | 20180 KB |
possible_3.txt | AC | 180 ms | 25428 KB |
possible_4.txt | AC | 134 ms | 24276 KB |
possible_5.txt | AC | 107 ms | 19668 KB |
possible_6.txt | AC | 136 ms | 20308 KB |
possible_7.txt | AC | 175 ms | 24360 KB |
possible_8.txt | AC | 151 ms | 20048 KB |
possible_9.txt | AC | 133 ms | 21844 KB |
random_0.txt | AC | 98 ms | 21204 KB |
random_1.txt | AC | 117 ms | 20812 KB |
random_2.txt | AC | 98 ms | 21972 KB |
random_3.txt | AC | 107 ms | 21076 KB |
random_4.txt | AC | 97 ms | 21588 KB |
random_5.txt | AC | 113 ms | 21076 KB |
random_6.txt | AC | 118 ms | 22356 KB |
random_7.txt | AC | 110 ms | 21204 KB |
random_8.txt | AC | 100 ms | 23380 KB |
random_9.txt | AC | 116 ms | 21972 KB |