| Task: | Forest density |
| Sender: | Terror2654 |
| Submission time: | 2025-09-22 17:29:32 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | RUNTIME ERROR | 0.37 s | details |
| #3 | RUNTIME ERROR | 0.37 s | details |
Code
#include <iostream>
using namespace std;
int main(){
long long n,m;
cin >> n >> m;
int prefix_sum[n+1][m+1];
for (int i = 1; i <= n; i++) {
string row;
cin >> row;
for (int j = 1; j <= n; j++) {
int t = 0;
if (row[j - 1] == '*') {
t = 1;
}
prefix_sum[i][j] = t + prefix_sum[i - 1][j] + prefix_sum[i][j - 1] - prefix_sum[i - 1][j - 1];
}
}
int ans[m];
for (int i = 0; i < m; i++) {
int y1, x1, y2, x2;
cin >> y1 >> x1 >> y2 >> x2;
ans[i] = prefix_sum[y2][x2] - prefix_sum[y1 - 1][x2] - prefix_sum[y2][x1 - 1] + prefix_sum[y1 - 1][x1 - 1];
}
for (int i = 0; i < m; i++) {
cout << ans[i] << endl;
}
return 0;
}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: RUNTIME ERROR
| input |
|---|
| 1000 200000 **.**.****..**.***..**.***.**.... |
| correct output |
|---|
| 41079 2824 15631 1548 8483 ... |
| user output |
|---|
| (empty) |
Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 200000 ******************************... |
| correct output |
|---|
| 1000000 1000000 1000000 1000000 1000000 ... |
| user output |
|---|
| (empty) |
