MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CPP/array-2d/prefix_2d_lr.cpp:6–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4int arr[n][n];
5long long pr[n][n];
6int main(){
7int arr[n][n];
8
9int n;
10cin>>n;
11for (int i = 1; i <= n; ++i)
12{
13 for (int j = 1; j <=n; ++j)
14 {
15 cin>>arr[i][j];
16 pr[i][j]=arr[i][j]+pr[i-1][j]+pr[i][j-1]-pr[i-1][j-1];
17 }
18}
19int t;
20cin>>t;
21while(t--){
22 int a,b,c,d;
23 cin>>a>>b>>c>>d;
24
25 cout<<pr[c][d]-pr[a-1][d]-pr[c][b-1]+pr[a-1][b-1]<<endl;
26
27}
28
29
30return 0;
31}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected