| Task: | Forest density |
| Sender: | duongha |
| Submission time: | 2025-09-22 17:20:58 +0300 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | details |
| #2 | WRONG ANSWER | 0.46 s | details |
| #3 | WRONG ANSWER | 0.43 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 1;
long long n, q;
long long r2, r1, c2, c1;
long long f[MAXN][MAXN];
void solve() {
cin >> n >> q;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) {
f[i][j] = 0;
}
}
for(int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
char st;
cin >> st;
if (st == '.') f[i][j] = 0;
else f[i][j] = 1;
f[i][j] += f[i - 1][j];
f[i][j] += f[i][j - 1];
f[i][j] -= f[i - 1][j - 1];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cout << f[i][j] << ' ';
}
cout << endl;
}
for (int i = 1; i <= q; i++) {
cin >> r1 >> c1 >> r2 >> c2 ;
cout << f[r2][c2] - f[r1-1][c2] - f[r2][c1-1] + f[r1-1][c1-1] << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 100 **.*.*.**. *.**.*..*. .*****.**. **....***. ... |
| correct output |
|---|
| 10 14 5 7 8 ... |
| user output |
|---|
| 1 2 2 3 3 4 4 5 6 6 2 3 4 6 6 8 8 9 11 11 2 4 6 9 10 13 13 15 18 18 3 6 8 11 12 15 16 1 ... Truncated |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 1000 200000 **.**.****..**.***..**.***.**.... |
| correct output |
|---|
| 41079 2824 15631 1548 8483 ... |
| user output |
|---|
| 1 2 2 3 4 4 5 6 7 8 8 8 9 10 1... Truncated |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000 200000 ******************************... |
| correct output |
|---|
| 1000000 1000000 1000000 1000000 1000000 ... |
| user output |
|---|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 ... Truncated |
