# Why wrong ? republic of coder final

why this wrong please guys look at the code below for the problem : Contest Page | CodeChef
i dont know why this is wrong could you find where is bug?

``````#include<bits/stdc++.h>
#define ll long long
#define pb(i) push_back(i)
#define vii vector<vector<int>>
#define vi vector<int>
#define vll vector<vector<ll>>
using namespace std;
void test_case(){
int n,m; cin>>n>>m;
vector<vector<int>> mat(n,vector<int>(m,0));
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cin>>mat[i][j];
}
}
vector<vector<int>> v(n+1,vector<int>(m+1,0));
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
v[i][j] = v[i-1][j] + v[i][j-1] + mat[i-1][j-1] - v[i-1][j-1];
}
}

int q;
cin>>q;

double ans = 0.0;
while(q--){
int x1,y1,x2,y2;
float p;
cin>>x1>>y1>>x2>>y2>>p;

double cur =v[x2][y2] - v[x2][y1-1] - v[x1-1][y2] + v[x1-1][y1-1];
ans += (double(cur)*double(p));
}

cout<<ans<<endl;

}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

int t = 1; // cin>>t;
while(t--){
test_case();
//cout<<"\n";
}
return 0;
}
``````

I think you have made mistake in making of vector v.
you have taken (1-based indexing) but in v[i-1][j] and v[i][j-1] ,it seems somewhat wrong.

I have also done using same approach.