///LW M4 ACC HAZ3L GAMED
///YARAB WALA...I MEAN YARAB ACC
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
const ll mod = (ll) 1e9 + 7;
const ll even = (ll) 1e9 + 2;
const ll oo= (ll) 1e16;
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n,m,x,y;
cin>>n>>m>>x>>y;
vector<vector<char>>v(n,vector<char>(m));
for (ll i=0; i<n; i++)
{
for (ll j=0; j<m; j++)
cin>>v[i][j];
}
vector<vector<ll>>frq(n+1,vector<ll>(m+1));
for (ll i=0; i<n; i++)
{
for (ll j=0; j<m; j++)
{
if (v[i][j]=='.' or v[i][j]=='M')continue;
if (n<m)
{
for (ll k=max(0ll,i-x); k<=min(n-1,i+x); k++)
{
frq[k][max(j-x,0ll)]++;
frq[k][min(j+x+1,m)]--;
}
}
else
{
for (ll k=max(0ll,j-x); k<=min(m-1,j+x); k++)
{
frq[max(i-x,0ll)][k]++;
frq[min(i+x+1,n)][k]--;
}
}
}
}
if (n<m)
{
for (ll i=0; i<n; i++)
{
for (ll j=1; j<m; j++)
frq[i][j]+=frq[i][j-1];
}
}
else
{
for (ll i=1; i<n; i++)
{
for (ll j=0; j<m; j++)
frq[i][j]+=frq[i-1][j];
}
}
ll ans=0;
for (ll i=0; i<n; i++)
{
for (ll j=0; j<m; j++)
{
if (v[i][j]=='M' and frq[i][j]>=y)ans++;
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
8 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2004 KB |
Output is correct |
2 |
Correct |
7 ms |
2072 KB |
Output is correct |
3 |
Correct |
6 ms |
2504 KB |
Output is correct |
4 |
Correct |
6 ms |
2132 KB |
Output is correct |
5 |
Correct |
5 ms |
2260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
12520 KB |
Output is correct |
2 |
Correct |
15 ms |
12496 KB |
Output is correct |
3 |
Correct |
15 ms |
12484 KB |
Output is correct |
4 |
Correct |
18 ms |
12520 KB |
Output is correct |
5 |
Correct |
16 ms |
12520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
8 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
6 ms |
2004 KB |
Output is correct |
17 |
Correct |
7 ms |
2072 KB |
Output is correct |
18 |
Correct |
6 ms |
2504 KB |
Output is correct |
19 |
Correct |
6 ms |
2132 KB |
Output is correct |
20 |
Correct |
5 ms |
2260 KB |
Output is correct |
21 |
Correct |
17 ms |
12520 KB |
Output is correct |
22 |
Correct |
15 ms |
12496 KB |
Output is correct |
23 |
Correct |
15 ms |
12484 KB |
Output is correct |
24 |
Correct |
18 ms |
12520 KB |
Output is correct |
25 |
Correct |
16 ms |
12520 KB |
Output is correct |
26 |
Correct |
41 ms |
6304 KB |
Output is correct |
27 |
Correct |
97 ms |
4876 KB |
Output is correct |
28 |
Correct |
61 ms |
5068 KB |
Output is correct |
29 |
Correct |
43 ms |
4948 KB |
Output is correct |
30 |
Correct |
43 ms |
6136 KB |
Output is correct |