| Task: | Forest density |
| Sender: | luukwin |
| Submission time: | 2025-09-22 16:46:43 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.04 s | details |
| #2 | WRONG ANSWER | 0.39 s | details |
| #3 | ACCEPTED | 0.31 s | details |
Code
n, q = [int(x) for x in input().split()]
array = [[0 for _ in range(n)] for _ in range(n)]
for i in range(0, n):
line = input()
for j in range(0, n):
if i != 0 and j != 0: array[i][j] = array[i-1][j] + array[i][j-1] - array[i-1][j-1]
elif i != 0: array[i][j] = array[i-1][j]
elif j != 0: array[i][j] = array[i][j-1]
if line[j] == "*": array[i][j] += 1
# for line in array: print(line)
output = []
for i in range(q):
coords = [int(x) - 1 for x in input().split()]
answer = array[coords[2]][coords[3]]
if coords[0] != 0: answer -= array[coords[0] - 1][coords[3]]
if coords[1] != 0: answer -= array[coords[2]][coords[1] - 1]
output.append(str(answer))
print("\n".join(output))Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 100 **.*.*.**. *.**.*..*. .*****.**. **....***. ... |
| correct output |
|---|
| 10 14 5 7 8 ... |
| user output |
|---|
| 7 11 1 4 8 ... Truncated |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 1000 200000 **.**.****..**.***..**.***.**.... |
| correct output |
|---|
| 41079 2824 15631 1548 8483 ... |
| user output |
|---|
| -79193 -161330 -8621 -436777 -37222 ... Truncated |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 1000 200000 ******************************... |
| correct output |
|---|
| 1000000 1000000 1000000 1000000 1000000 ... |
| user output |
|---|
| 1000000 1000000 1000000 1000000 1000000 ... Truncated |
