Submission #1177293
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int H, W; cin >> H >> W;
vector<string>v(H); rep(i, 0, H)cin >> v[i];
vector<string>before(v);
auto within = [&](int x, int y) {
return 0 <= x&&x < H && 0 <= y&&y < W;
};
int dx[]{ 1,1,0,-1,-1,-1,0,1 }, dy[]{ 0,1,1,1,0,-1,-1,-1 };
rep(i, 0, H)rep(j, 0, W) {
if (v[i][j] == '.') {
rep(k, 0, 8) {
int X = i + dx[k], Y = j + dy[k];
if (within(X, Y))before[X][Y] = '.';
}
}
}
vector<string>after(before);
rep(i, 0, H)rep(j, 0, W) {
if (before[i][j] == '#') {
rep(k, 0, 8) {
int X = i + dx[k], Y = j + dy[k];
if (within(X, Y))after[X][Y] = '#';
}
}
}
auto vec_equal = [&](vector<string>&a, vector<string>&b) {
rep(i, 0, H)rep(j, 0, W)if (a[i][j] != b[i][j])return false;
return true;
};
if (vec_equal(after, v)) {
cout << "possible" << endl;
rep(i, 0, H)cout << before[i] << endl;
}
else cout << "impossible" << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - 画像処理高橋君 |
User |
norma |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1593 Byte |
Status |
AC |
Exec Time |
1 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 |
1 ms |
256 KB |
possible_2.txt |
AC |
1 ms |
256 KB |
possible_3.txt |
AC |
1 ms |
256 KB |
possible_4.txt |
AC |
1 ms |
256 KB |
possible_5.txt |
AC |
1 ms |
256 KB |
possible_6.txt |
AC |
1 ms |
256 KB |
possible_7.txt |
AC |
1 ms |
256 KB |
possible_8.txt |
AC |
1 ms |
256 KB |
possible_9.txt |
AC |
1 ms |
256 KB |
random_0.txt |
AC |
1 ms |
256 KB |
random_1.txt |
AC |
1 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 |
1 ms |
256 KB |
random_7.txt |
AC |
1 ms |
256 KB |
random_8.txt |
AC |
1 ms |
256 KB |
random_9.txt |
AC |
1 ms |
256 KB |