提出 #764046
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
int H,W;
vector<string> img;
bool put [100] [100];
int dx [] = {-1,1,0,0,-1,1,-1,1,0};
int dy [] = {0,0,-1,1,-1,-1,1,1,0};
bool in_range(int y,int x){
return y >= 0 && y < H && x >= 0 && x < W;
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> H >> W;
for(int i = 0;i < H;i++){
string S;
cin >> S;
img.push_back(S);
}
for(int i = 0;i < H;i++){
for(int j = 0;j < W;j++){
if(img [i] [j] == '#'){
bool flag = true;
for(int k = 0;k < 9;k++){
int y = i + dy [k],x = j + dx [k];
if(in_range(y,x)){
if(img [y] [x] == '.'){
flag = false;
}
}
}
if(flag == true){
put [i] [j] = true;
}
}
}
}
for(int i = 0;i < H;i++){
for(int j = 0;j < W;j++){
if(img [i] [j] == '#'){
bool flag = false;
for(int k = 0;k < 9;k++){
int y = i + dy [k],x = j + dx [k];
if(in_range(y,x)){
if(put [y] [x] == true){
flag = true;
}
}
}
if(flag == false){
cout << "impossible" << endl;
return 0;
}
}
}
}
cout << "possible" << endl;
for(int i = 0;i < H;i++){
for(int j = 0;j < W;j++){
cout << (put [i] [j] ? "#" : ".");
}
cout << endl;
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - 画像処理高橋君 |
| ユーザ | cmmnd17 |
| 言語 | C++14 (GCC 5.4.1) |
| 得点 | 100 |
| コード長 | 1327 Byte |
| 結果 | AC |
| 実行時間 | 6 ms |
| メモリ | 256 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 100 / 100 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| example_0.txt | AC | 4 ms | 256 KiB |
| example_1.txt | AC | 6 ms | 256 KiB |
| example_2.txt | AC | 4 ms | 256 KiB |
| handmade_0.txt | AC | 4 ms | 256 KiB |
| handmade_1.txt | AC | 4 ms | 256 KiB |
| possible_0.txt | AC | 5 ms | 256 KiB |
| possible_1.txt | AC | 6 ms | 256 KiB |
| possible_2.txt | AC | 5 ms | 256 KiB |
| possible_3.txt | AC | 5 ms | 256 KiB |
| possible_4.txt | AC | 5 ms | 256 KiB |
| possible_5.txt | AC | 5 ms | 256 KiB |
| possible_6.txt | AC | 5 ms | 256 KiB |
| possible_7.txt | AC | 6 ms | 256 KiB |
| possible_8.txt | AC | 5 ms | 256 KiB |
| possible_9.txt | AC | 5 ms | 256 KiB |
| random_0.txt | AC | 4 ms | 256 KiB |
| random_1.txt | AC | 4 ms | 256 KiB |
| random_2.txt | AC | 4 ms | 256 KiB |
| random_3.txt | AC | 4 ms | 256 KiB |
| random_4.txt | AC | 4 ms | 256 KiB |
| random_5.txt | AC | 4 ms | 256 KiB |
| random_6.txt | AC | 4 ms | 256 KiB |
| random_7.txt | AC | 4 ms | 256 KiB |
| random_8.txt | AC | 6 ms | 256 KiB |
| random_9.txt | AC | 4 ms | 256 KiB |