Advertisement
a53

ZOO

a53
Oct 18th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <fstream>
  2. #define Nmax 101
  3. #define LL long long
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n,m,x,Q,i,j,i1,j1,i2,j2;
  9. LL SP[Nmax][Nmax];
  10. ifstream f("zoo.in");
  11. f>>n>>m;
  12. for(i=1;i<=n;++i)
  13. for(j=1;j<=m;++j)
  14. f>>x,SP[i][j]=SP[i-1][j]+SP[i][j-1]-SP[i-1][j-1]+x;
  15. f>>Q;
  16. ofstream g("zoo.out");
  17. while(Q--)
  18. f>>i1>>j1>>i2>>j2,g<<SP[i2][j2]-SP[i1-1][j2]-SP[i2][j1-1]+SP[i1-1][j1-1]<<'\n';
  19. f.close();
  20. g.close();
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement