Task: | Forest density |
Sender: | htoik |
Submission time: | 2024-09-23 17:36:14 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.53 s | details |
#3 | ACCEPTED | 0.52 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] 21 | for(int i=0; i<n; i++){ | ~^~ input/code.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] 25 | for(int k=0; k<n; k++){ | ~^~ input/code.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] 33 | for(int i=0; i<q; i++){ | ~^~
Code
#include <bits/stdc++.h>using namespace std;typedef unsigned long long ull;inline ull andmask(unsigned n){return ~((~0ULL) << n);}ull sums[1001][1001];int main(){unsigned n, q;cin >> n >> q;vector<string> strs;strs.reserve(n);vector<ull> ls;ls.reserve(n);for(int i=0; i<n; i++){string s;cin >> s;for(int k=0; k<n; k++){sums[i][k] = (s[k] == '*')+ (i > 0 ? sums[i-1][k] : 0)+ (k > 0 ? sums[i][k-1] : 0)- (i > 0 && k > 0 ? sums[i-1][k-1] : 0);}}for(int i=0; i<q; i++){ull y1, x1, y2, x2;cin >> y1 >> x1 >> y2 >> x2;ull sum = sums[y2-1][x2-1]- (x1-1 ? sums[y2-1][x1-2] : 0)- (y1-1 ? sums[y1-2][x2-1] : 0)+ (x1-1 && y1-1 ? sums[y1-2][x1-2] : 0);cout << sum << endl;}// vector<ull> rls;// rls.reserve(n);// for(int i=0; i<n; i++){// ull ss = 0;// for(int j=0; j<n; j++){// ss = (ss << 1) & (strs[j][i] == '*');// }// rls.push_back(ss);// }}
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 |