| Task: | Forest density |
| Sender: | aalto26dm_025 |
| Submission time: | 2026-09-21 17:55:14 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.00 s | details |
| #2 | RUNTIME ERROR | 0.01 s | details |
| #3 | RUNTIME ERROR | 0.01 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:41:9: warning: unused variable 'full_array_size' [-Wunused-variable]
41 | int full_array_size = 2 * base_array_size;
| ^~~~~~~~~~~~~~~Code
#include <iostream>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int sum_in_area(int y1, int x1, int y2, int x2, vector<vector<int>> forest)
{
int sum = 0;
sum += forest[x2][y2];
sum -= forest[x1 - 1][y2];
sum -= forest[x2][y1 - 1];
sum += forest[x1 - 1][y1 - 1];
return sum;
}
inline void construct(const int &end, const int &line, const int &value, vector<vector<int>> & forest)
{
}
void add(int k, int x, vector<int> & tree)
{
int n = tree.size() / 2;
k += n;
tree[k] = x;
for (k /= 2; k >= 1; k /= 2)
{
tree[k] = tree[2*k] + tree[2*k+1];
}
}
int main()
{
int forest_size, n_queries;
cin >> forest_size >> n_queries;
int base_array_size = pow(2, ceil(log2(forest_size)));
int full_array_size = 2 * base_array_size;
vector<vector<int>> forest(forest_size + 1, vector<int>(forest_size + 1, 0));
for(int l = 1; l < forest_size + 1; ++l)
{
string temp;
cin >> temp;
for(int c = 1; c < forest_size + 1; ++c)
{
if(temp[c - 1] == '.') forest[l][c] = sum_in_area(0, 0, c, l, forest) + 0;
if(temp[c - 1] == '*') forest[l][c] = sum_in_area(0, 0, c, l, forest) + 1;
}
}
for(int i = 0; i < n_queries; ++i)
{
int y1, x1, y2, x2;
cin >> y1 >> x1 >> y2 >> x2;
cout << sum_in_area(x1, y1, x2, y2, forest) << endl;
}
}Test details
Test 1
Verdict: RUNTIME ERROR
| input |
|---|
| 10 100 **.*.*.**. *.**.*..*. .*****.**. **....***. ... |
| correct output |
|---|
| 10 14 5 7 8 ... |
| user output |
|---|
| (empty) |
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) |
