Task: | Forest density |
Sender: | Rasse |
Submission time: | 2024-09-23 16:40:41 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.53 s | details |
#3 | ACCEPTED | 0.51 s | details |
Code
// Online C++ compiler to run C++ program online#include <iostream>#include <vector>#include <climits>using namespace std;int main() {int n, q;cin >> n >> q;vector<vector<int>> trees(n+1, vector<int>(n+1, 0));for (int y = 0; y < n; y++){string s;cin >> s;for (int x = 0; x < n; x++){trees[y+1][x+1] = (s[x] == '*') + trees[y][x+1] + trees[y+1][x] - trees[y][x];}}for (int i = 0; i < q; i++){int y1, x1, y2, x2;cin >> y1 >> x1 >> y2 >> x2;int res = trees[y2][x2] - trees[y1-1][x2] - trees[y2][x1-1] + trees[y1-1][x1-1];cout << res << 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: 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 |