Task: | Forest density |
Sender: | arnxxau |
Submission time: | 2024-09-23 16:46:24 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | RUNTIME ERROR |
test | verdict | time | |
---|---|---|---|
#1 | RUNTIME ERROR | 0.00 s | details |
#2 | RUNTIME ERROR | 0.07 s | details |
#3 | RUNTIME ERROR | 0.07 s | details |
Compiler report
input/code.cpp: In function 'int preCalc(std::vector<std::vector<int> >, std::vector<std::vector<int> >&)': input/code.cpp:20:1: warning: no return statement in function returning non-void [-Wreturn-type] 20 | } | ^
Code
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; int preCalc(vector<vector<int> > v, vector<vector<int> >& aux) { int n = v.size(); aux = v; for (int i = 1; i < n; i++) for (int j = 0; j < n; j++) aux[i][j] = v[i][j] + aux[i - 1][j]; for (int i = 0; i < n; i++) for (int j = 1; j < n; j++) aux[i][j] += aux[i][j - 1]; } int calc(vector<vector<int> >& aux, int tli, int tlj, int rbi, int rbj) { int sol = aux[rbi][rbj]; if (tli > 0) sol -= aux[tli - 1][rbj]; if (tlj > 0) sol -= aux[rbi][tlj - 1]; if (tli > 0 && tlj > 0) sol += aux[tli - 1][tlj - 1]; return sol; } int main() { // cin >> n >> m; // vector<vector<char> > map(n, vector<char>(m)); // vector<vector<pair<int, int> > > path(n, vector<pair<int, int> >(m)); int n, q; cin >> n >> q; vector<vector<int> > f(n, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char x; cin >> x; if (x == '.') f[i][j] = 0; else f[i][j] = 1; } } vector<vector<int> > aux(n, vector<int>(n)); preCalc(f, aux); for (int i = 0; i < q; i++) { int tli, tlj, rbi, rbj; cin >> tli >> tlj >> rbi >> rbj; cout << calc(aux, tli - 1, tlj - 1, rbi - 1, rbj - 1) << 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) |