Submission details
Task:Forest density
Sender:erikpeik
Submission time:2025-09-22 16:51:21 +0300
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2--details
#3--details

Code

size, q = input().split()
map_data = []
for _ in range(int(size)):
    map_data.append(input())

for _ in range(int(q)):
    y1, x1, y2, x2 = [int(i) for i in input().split()]
    count = 0
    for y in range(y1, y2 + 1):
        for x in range(x1, x2 + 1):
            # print(f'position: ({y}, {x})')
            if map_data[y - 1][x - 1] == "*":
                count += 1
                # print(f'({y}, {x})')
    print(count)


# for row in map_data:
#     print(row)

Test details

Test 1

Verdict: ACCEPTED

input
10 100
**.*.*.**.
*.**.*..*.
.*****.**.
**....***.
...

correct output
10
14
5
7
8
...

user output
10
14
5
7
8
...
Truncated

Test 2

Verdict:

input
1000 200000
**.**.****..**.***..**.***.**....

correct output
41079
2824
15631
1548
8483
...

user output
(empty)

Test 3

Verdict:

input
1000 200000
******************************...

correct output
1000000
1000000
1000000
1000000
1000000
...

user output
(empty)