Task: | Forest density |
Sender: | esya_rae |
Submission time: | 2024-09-23 16:40:22 +0300 |
Language: | Python3 (PyPy3) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.72 s | details |
#3 | ACCEPTED | 0.67 s | details |
Code
n, q = map(int, input().split()) x = [[0] * (n + 1) for _ in range(n + 1)] line = input() for j in range(1, n + 1): if line[j - 1] == '*': x[1][j] = x[1][j - 1] + 1 else: x[1][j] = x[1][j - 1] for i in range(2, n + 1): line = input() for j in range(1, n + 1): x[i][j] = x[i][j - 1] + x[i - 1][j] - x[i - 1][j - 1] if line[j - 1] == '*': x[i][j] += 1 for i in range(q): a, b, c, d = map(int, input().split()) print(x[c][d] - x[a - 1][d] - x[c][b - 1] + x[a - 1][b - 1])
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: ACCEPTED
input |
---|
1000 200000 **.**.****..**.***..**.***.**.... |
correct output |
---|
41079 2824 15631 1548 8483 ... |
user output |
---|
41079 2824 15631 1548 8483 ... Truncated |
Test 3
Verdict: ACCEPTED
input |
---|
1000 200000 ******************************... |
correct output |
---|
1000000 1000000 1000000 1000000 1000000 ... |
user output |
---|
1000000 1000000 1000000 1000000 1000000 ... Truncated |