CSES - Aalto Competitive Programming 2024 - wk4 - Mon - Results
Submission details
Task:Forest density
Sender:bielaltes
Submission time:2024-09-23 17:05:27 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2--details
#3--details

Code

#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <map>
#include <math.h>
#include <cstdlib>
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    int n, q;

    cin >> n >> q;

    auto forest = vector<string >(n);

    for (int i = 0; i < n; ++i){
        cin >> forest[i];
    }

    for (int i = 0; i < q; ++i){
        int sum = 0;
        int x1, x2, y1, y2;
        cin >> y1 >>x1 >>y2 >>x2;
        for (int x = x1; x <= x2; ++x){
            for (int y = y1; y <= y2; ++y)
                if (forest[y-1][x-1] == '*')
                    sum++;
        }
        cout << sum << endl;
    }
}

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)