#include <bits/stdc++.h>
//@Whisper__
#pragma GCC optimize("Ofast")
#define ii pair<int,int>
#define tii tuple<int,int,int>
#define pr priority_queue< ll , vector<ll> , greater<ll> >
#define ep emplace
#define pb push_back
#define f first
#define s second
#define all(x) begin(x) , end(x)
#define all1(x) x + 1 , x + n + 1
using namespace std;
using ll = long long;
using str = string;
using ld = long double;
const ll dx[4] = { -1, 0, 0 , 1};
const ll dy[4] = { 0, -1, 1, 0};
const ll P[4] = {'U', 'L', 'R', 'D'};
const ll dx1[8] = {-1, -1, 1, 1, 0, 0, -1, 1};
const ll dy1[8] = {-1, 1, -1, 1, -1, 1, 0, 0};
const ll linf = ( 1e18 + 5 );
const int N = 1e6 + 5;
const int inf = (1e9 + 5);
const int MOD = 1e9 + 7;
template<class T> T ckmax( T a, T b ){ return a > b ? a : b; }
template<class T> T ckmin( T a, T b ){ return a < b ? a : b; }
class Jax{
public:
bool isOdd( ll n ){
return n & 1;
}
bool isOk( ll n , ll m , ll x, ll y ){
return x >= 1 && x <= n && y >= 1 && y <= m;
}
ll BinPow( ll a, ll b ){
if ( b == 0 ) return 1;
ll x = BinPow( a, b / 2 );
if ( b % 2 ){
return ( x % MOD ) * ( x % MOD ) * ( a % MOD ) % MOD;
}
else{
return ( x % MOD ) * ( x % MOD ) % MOD;
}
}
void Erathenes( bool prime[] , ll n ){
for ( int i = 1 ; i <= n ; i++ ) prime[i] = true;
prime[1] = false;
for ( int i = 2 ; i <= n ; i++ ){
if ( prime[i] ){
for ( int j = 2 * i ; j <= n ; j += i ){
prime[j] = false;
}
}
}
}
bool Prime ( ll n ){
if ( n < 2 ) return false;
for ( int i = 2 ; i <= sqrt(n) ; i++ ){
if ( n % i == 0 ) return false;
}
return true;
}
ll SumDigit( ll n ){
ll res = 0;
while (n){
res += n % 10;
n /= 10;
}
return res;
}
} Jax;
class Segment{
public:
void BuildTree( ll a[] , ll Tree[] , ll id , ll l , ll r , ll type ){
if ( l == r ){
Tree[id] = a[l];
return;
}
ll mid = ( l + r ) / 2;
BuildTree( a , Tree , 2 * id , l , mid , type );
BuildTree( a , Tree , 2 * id + 1 , mid + 1 , r , type );
if ( !type ){
Tree[id] = Tree[2 * id] + Tree[2 * id + 1];
}
if ( type == 1 || type == 2 ){
Tree[id] = ( type == 1 ) ? max( Tree[2 * id] , Tree[2 * id + 1] ) : min( Tree[2 * id], Tree[2 * id + 1] );
}
}
ll get( ll Tree[] , ll id , ll l , ll r , ll u , ll v , ll type ){
if ( u > r || v < l ){
if ( !type ) return 0;
else{
if ( type == 1 || type == 2 ){
ll res = ( type == 1 ) ? -inf : inf;
return res;
}
}
}
if ( u <= l && v >= r ){
return Tree[id];
}
ll mid = ( l + r ) / 2;
ll t1 = get( Tree , 2 * id , l , mid , u , v , type );
ll t2 = get( Tree , 2 * id + 1 , mid + 1, r , u , v , type );
if ( !type ) return t1 + t2;
if ( type == 1 || type == 2 ){
return ( type == 1 ) ? max( t1, t2 ) : min( t1, t2 );
}
}
void UpVal( ll Tree[] , ll Lazy[] , ll id ){
// for Max, Min
Tree[2 * id] += Lazy[id];
Tree[2 * id + 1] += Lazy[id];
Lazy[2 * id] += Lazy[id];
Lazy[2 * id + 1] += Lazy[id];
Lazy[id] = 0;
}
void Down( ll Tree[] , ll Lazy[] , ll id , ll l , ll r ){
// for Sum of Subquence
if ( Tree[id] ){
ll mid = ( l + r ) / 2;
Tree[2 * id] += Lazy[id] * ( mid - l + 1 );
Tree[2 * id + 1] += Lazy[id] * ( r - mid );
Lazy[2 * id] += Lazy[id];
Lazy[2 * id + 1] += Lazy[id];
Lazy[id] = 0;
}
return;
}
} Segment;
char a[1001][1001];
bool vst[1001][1001];
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
// freopen("programming.inp","r",stdin);
// freopen("programming.out","w",stdout);
ll n, m; cin >> n >> m;
for ( int i = 1; i <= n ; i++ ){
for ( int j = 1 ; j <= m ; j++ ){
cin >> a[i][j];
}
}
for ( int i = 1 ; i <= n ; i++ ){
for ( int j = 1 ; j <= m ; j++ ){
if ( a[i][j] == '#' && !vst[i][j] && a[i][j + 1] != '#'){
if ( j + 1 <= m ){
a[i][j + 1] = '#';
vst[i][j + 1] = true;
}
}
if ( a[i][j] == '#' && !vst[i][j] && a[i + 1][j + 1] != '#'){
if ( i + 1 <= n && j + 1 <= m ){
a[i + 1][j + 1] = '#';
vst[i + 1][j + 1] = true;
}
}
if ( a[i][j] == '#' && !vst[i][j] && a[i + 1][j] != '#'){
if ( i + 1 <= n ){
a[i + 1][j] = '#';
vst[i + 1][j] = true;
}
}
}
}
for ( int i = 1 ; i <= n ; i++ ){
for ( int j = 1 ; j <= m ; j++ ){
cout << a[i][j];
}
cout << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |