# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1238239 | caterpillow | Collecting Mushrooms (NOI18_collectmushrooms) | Pypy 3 | 192 ms | 60380 KiB |
rs, cs, d, k = map(int, input().split())
grid = [input() for r in range(rs)]
pfx = [[0] * (cs + 1) for _ in range(rs + 1)]
for r in range(rs):
for c in range(cs):
if grid[r][c] == 'S':
r1 = max(0, r - d)
c1 = max(0, c - d)
r2 = min(rs, r + d + 1)
c2 = min(cs, c + d + 1)
pfx[r1][c1] += 1
pfx[r1][c2] -= 1
pfx[r2][c1] -= 1
pfx[r2][c2] += 1
for r in range(rs + 1):
for c in range(cs):
pfx[r][c + 1] += pfx[r][c]
for r in range(rs):
for c in range(cs + 1):
pfx[r + 1][c] += pfx[r][c]
ans = 0
for r in range(rs):
for c in range(cs):
if pfx[r][c] >= k and grid[r][c] == 'M':
ans += 1
print(ans)
Compilation message (stdout)
# | 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... |