Submission #1247535
Source Code Expand
#include <iostream> using namespace std; int dx[8] = {-1,0,1,-1,1,-1,0,1}; int dy[8] = {-1,-1,-1,0,0,1,1,1}; int H,W; char gazou[101][101]; char ans[101][101]; char ans2[101][101]; bool tmp[101][101]; void init() { for(int i = 0; i < H; i++) fill(tmp[i], tmp[i]+W, true); } int main() { cin >> H >> W; for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { cin >> gazou[i][j]; ans[i][j] = ans2[i][j] = gazou[i][j]; } } init(); for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { if(ans[i][j] == '.') { tmp[i][j] = false; for(int k = 0; k < 8; k++) { int n_x = j + dx[k]; int n_y = i + dy[k]; if(n_x >= 0 && n_x < W && n_y >= 0 && n_y < H) { tmp[n_y][n_x] = false; } } } } } for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { if(tmp[i][j]) ans[i][j] = '#'; else ans[i][j] = '.'; } } for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { if(ans[i][j] == '#') { for(int k = 0; k < 8; k++) { int n_x = j + dx[k]; int n_y = i + dy[k]; if(n_x >= 0 && n_x < W && n_y >= 0 && n_y < H) { tmp[n_y][n_x] = true; } } } } } for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { if(tmp[i][j])ans2[i][j] = '#'; else ans2[i][j] = '.'; } } bool is_same = true; for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { if(ans2[i][j] != gazou[i][j]) { is_same = false; break; } } } if(is_same) { cout << "possible" <<endl; for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { cout << ans[i][j]; } cout <<endl; } } else cout << "impossible" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 画像処理高橋君 |
User | shossie1016 |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1846 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 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 | 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 | AC | 1 ms | 256 KB |
possible_1.txt | AC | 2 ms | 256 KB |
possible_2.txt | AC | 2 ms | 256 KB |
possible_3.txt | AC | 2 ms | 256 KB |
possible_4.txt | AC | 1 ms | 256 KB |
possible_5.txt | AC | 1 ms | 256 KB |
possible_6.txt | AC | 2 ms | 256 KB |
possible_7.txt | AC | 2 ms | 256 KB |
possible_8.txt | AC | 2 ms | 256 KB |
possible_9.txt | AC | 2 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 | 1 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 |