-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Bombs.cpp
More file actions
56 lines (41 loc) · 1004 Bytes
/
B_Bombs.cpp
File metadata and controls
56 lines (41 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Mohit Verma "mohitvdx"
// problem:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = LLONG_MAX >> 1;
void solve(){
int r, c; cin>>r>>c;
vector<string> s(r);
for(int i=0; i<r; i++){
cin>>s[i];
}
vector<vector<bool>> bombs(r,vector<bool>(c,false));
for(int i=0; i<r; i++){
for(int j=0; j<c; j++){
if(!isdigit(s[i][j])) continue;
int power = s[i][j]-'0';
for(int nr=0; nr<r; nr++){
for(int nc=0; nc<c; nc++){
if(abs(nr-i)+abs(nc-j)<=power) bombs[nr][nc] = true;
}
}
}
}
for(int i =0; i<r; i++){
for(int j=0; j<c; j++){
if(bombs[i][j]==true) s[i][j]='.';
}
}
for(auto k:s) cout<<k<<'\n';
}
signed main(){
ios::sync_with_stdio(false); cin.tie(NULL); // fast IO
// int t; cin>>t;
// while(t--){
solve();
// }
}
/*
*/