이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
signed main()
{
fast();
int n, m, D, k;
cin >> n >> m >> D >> k;
int diff[n+1][m+1];
for(int i = 0; i <= n; i++)
{
for(int j = 0; j <= m; j++)
diff[i][j] = 0;
}
int grid[n][m];
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
char t;
cin >> t;
grid[i][j] = t-'M';
if(t=='S')
{
int a = max(i-D, 0ll);
int b = max(j-D, 0ll);
int c = min(i+D, n-1);
int d = min(j+D, m-1);
diff[a][b]++;
diff[c+1][d+1]++;
diff[a][d+1]--;
diff[c+1][b]--;
}
}
}
for(int i = 0; i < n; i++)
{
for(int j = 1; j < m; j++)
diff[i][j]+=diff[i][j-1];
}
int ans = 0;
for(int i = 1; i < n; i++)
{
for(int j = 0; j < m; j++)
diff[i][j]+=diff[i-1][j];
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
if(diff[i][j] >= k && grid[i][j] == 0)
ans++;
}
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |