Submission #1676857
Source Code Expand
#include<bits/stdc++.h> using namespace std; int dh[9]={-1, -1, -1, 0, 0, 0, 1, 1, 1}; int dw[9]={-1, 0, 1, -1, 0, 1, -1, 0, 1}; int main(){ int H, W; cin>>H>>W; string s[110]; string ans[110]; string judge[110]; for(int i=0;i<H;i++){ cin>>s[i]; } bool res=true; for(int h=0;h<H;h++){ for(int w=0;w<W;w++){ ans[h]+=s[h][w]; judge[h]+=s[h][w]; if(s[h][w]=='#'){ bool flag=true; int now=0; for(int i=0;i<9;i++){ if(i==3||i==6){ now++; } int nowh=h+dh[i], noww=w+dw[i]; if(nowh<0||nowh>H-1||noww<0||noww>W-1){ continue; } if(s[nowh][noww]=='.'){ flag=false; break; } } if(!flag){ ans[h][w]='.'; } if(flag){ judge[h][w]='.'; } } } } for(int i=1;i<H-1;i++){ for(int j=1;j<W-1;j++){ if(judge[i][j]=='.'){ if(judge[i-1][j]=='#'&&judge[i+1][j]=='#'&&judge[i][j-1]=='#'&&judge[i][j+1]=='#'){ res=false; break; } } } if(!res)break; } /*for(int i=0;i<H;i++){ cout<<judge[i]<<endl; }*/ if(res){ cout<<"possible"<<endl; for(int i=0;i<H;i++){ cout<<ans[i]<<endl; } } else{ cout<<"impossible"<<endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 画像処理高橋君 |
User | agony |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2521 Byte |
Status | WA |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 1 ms | 256 KB |
example_1.txt | AC | 1 ms | 256 KB |
example_2.txt | AC | 1 ms | 256 KB |
handmade_0.txt | AC | 1 ms | 256 KB |
handmade_1.txt | AC | 1 ms | 256 KB |
possible_0.txt | WA | 1 ms | 256 KB |
possible_1.txt | WA | 2 ms | 256 KB |
possible_2.txt | WA | 2 ms | 256 KB |
possible_3.txt | WA | 2 ms | 256 KB |
possible_4.txt | WA | 1 ms | 256 KB |
possible_5.txt | AC | 1 ms | 256 KB |
possible_6.txt | WA | 1 ms | 256 KB |
possible_7.txt | WA | 2 ms | 256 KB |
possible_8.txt | WA | 2 ms | 256 KB |
possible_9.txt | WA | 1 ms | 256 KB |
random_0.txt | AC | 1 ms | 256 KB |
random_1.txt | AC | 2 ms | 256 KB |
random_2.txt | AC | 1 ms | 256 KB |
random_3.txt | AC | 1 ms | 256 KB |
random_4.txt | AC | 1 ms | 256 KB |
random_5.txt | AC | 2 ms | 256 KB |
random_6.txt | AC | 2 ms | 256 KB |
random_7.txt | AC | 2 ms | 256 KB |
random_8.txt | AC | 1 ms | 256 KB |
random_9.txt | AC | 1 ms | 256 KB |