#ifndef INCLUDED_MAIN #define INCLUDED_MAIN #include __FILE__ // このファイル自体をインクルード void solve() { ll H, W; cin >> H >> W; vector S(H); REP(i, H) cin >> S[i]; REP(i, H) { REP(j, W) { if (S[i][j] == '9') { if (j > 0 && S[i][j - 1] == 'y') { S[i][j - 1] = 'Y'; S[i][j - 5] = '#'; } else if (j < W - 1 && S[i][j + 1] == 'y') { S[i][j + 1] = 'Y'; S[i][j + 5] = '#'; } } } } REP(i, H) { REP(j, W) { if (S[i][j] == '#') { S[i][j] = 'y'; } } } REP(i, H) { cout << S[i] << endl; } } signed main() { solve(); return 0; } #else // INCLUDED_MAIN using namespace std; #include #include using namespace atcoder; #define CPP_STR(x) CPP_STR_I(x) #define CPP_CAT(x, y) CPP_CAT_I(x, y) #define CPP_STR_I(args...) #args #define CPP_CAT_I(x, y) x##y #define ASSERT(expr...) assert((expr)) using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using f32 = float; using f64 = double; // }}} constexpr i64 INF = 1'010'000'000'000'000'017LL; constexpr int inf = 1073741823; constexpr i64 MOD = 998244353LL; constexpr f64 EPS = 1e-12; constexpr f64 PI = 3.14159265358979323846; #define M5 100007 #define M9 1000000000 #define F first #define S second // util {{{ #define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i) #define RFOR(i, start, end) for (ll i = start - 1; i >= end; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define ll long long int #define VI vector #define VVI vector #define VC vector #define VVC vector #define VS vector #define VVS vector #define VB vector #define VVB vector #define VM vector #define VVM vector #define vec vector #define pb push_back #define ISD true #define debug(x) \ if (ISD) \ cout << #x << ": " << x << endl #define DEBUG(x) cout << #x << ": " << x << endl template i64 SIZE(const C &c) { return static_cast(c.size()); } template i64 SIZE(const T (&)[N]) { return static_cast(N); } template > bool chmax(T &xmax, const U &x, Comp comp = {}) { if (comp(xmax, x)) { xmax = x; return true; } return false; } template > bool chmin(T &xmin, const U &x, Comp comp = {}) { if (comp(x, xmin)) { xmin = x; return true; } return false; } // }}} // init {{{ struct ProconInit { static constexpr int IOS_PREC = 15; static constexpr bool AUTOFLUSH = false; ProconInit() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(IOS_PREC); if (AUTOFLUSH) cout << unitbuf; } } PROCON_INIT; // }}} //-------------------------------------------------------------------- bool isKaibun(string st) { int n = st.length(); REP(i, n / 2) { if (st[i] != st[n - i - 1]) { return false; } } return true; } int toInt(char a) { return a - '0'; } ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } vector enum_divisors(long long N) { vector res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.push_back(i); // 重複しないならば i の相方である N/i も push if (N / i != i) res.push_back(N / i); } } // 小さい順に並び替える sort(res.begin(), res.end()); return res; } vector> prime_factorize(long long N) { vector> res; for (long long a = 2; a * a <= N; ++a) { if (N % a != 0) continue; long long ex = 0; // 指数 // 割れる限り割り続ける while (N % a == 0) { ++ex; N /= a; } // その結果を push res.push_back({a, ex}); } // 最後に残った数について if (N != 1) res.push_back({N, 1}); return res; } long long GCD(long long a, long long b) { if (b == 0) return a; else return GCD(b, a % b); } ll lcm(ll a, ll b) { return a * b / GCD(a, b); } long long safe_pow(long long a, long long b) { long long res = 1; for (long long i = 0; i < b; i++) { double dres = res; dres *= a; if (dres > 2e18) { return 2e18; } res *= a; } return res; } long long sqrt_floor(long long x) { long long l = 0, r = 2e9; while (l <= r) { long long t = (l + r) / 2; if (t * t > x) { r = t - 1; } else { l = t + 1; } } return r; } ll popcount(ll bit) { ll c = 0; while (bit > 0) { c += bit % 2; bit /= 2; } return c; } bool on(ll N, ll K) { return N & (1LL << K); } template std::ostream &operator<<(std::ostream &os, std::pair p) { os << "{" << p.first << "," << p.second << "}"; return os; } bool outof(ll y, ll x, ll h, ll w) { return y < 0 || x < 0 || y >= h || x >= w; }; // 配列の要素を空白区切りで出力 第二引数をtrueにすると改行区切り template inline void pv(const vector &v, bool split_line = false) { if (v.empty()) { cout << "This vector is empty." << endl; return; } const bool isValue = is_integral::value; for (int i = 0; i < (int)v.size(); i++) { if (isValue) { if ((v[i] == inf) || (v[i] == INF)) cout << 'x' << " \n"[split_line || i + 1 == (int)v.size()]; else cout << v[i] << " \n"[split_line || i + 1 == (int)v.size()]; } else cout << v[i] << " \n"[split_line || i + 1 == (int)v.size()]; } } template inline void pv(const vector> &v, bool split_line = false) { if (v.empty()) { cout << "This vector is empty." << endl; return; } for (int i = 0; i < (int)v.size(); i++) { cout << '{'; auto a = v[i].F; auto b = v[i].S; pair isValue = {is_integral::value, is_integral::value}; if (isValue.first) { if (a == inf || a == INF) cout << "x,"; else cout << a << ","; } else cout << a << ","; if (isValue.second) { if (b == inf || b == INF) cout << "x,"; else cout << b; } else cout << b; cout << "}" << " \n"[split_line || i + 1 == (int)v.size()]; } } #endif // INCLUDED_MAIN