Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

Daniela000 Mar 31st, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("zoo.in");
  7. ofstream fout("zoo.out");
  8.  
  9. const int Dim = 1001;
  10. long long int a[Dim][Dim], n, m;
  11. int Q;
  12.  
  13. long long int s[Dim][Dim];
  14.  
  15. int main()
  16. {
  17.     fin >> n >> m;
  18.     for (int i = 1; i <= n; ++i)
  19.         for (int j = 1; j <= m; ++j)
  20.             fin >> a[i][j];
  21.  
  22.     for (int i = 1; i <= n; ++i)
  23.         for (int j = 1; j <= m; ++j)
  24.             s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
  25.  
  26.     int i1, j1, i2, j2;
  27.     fin >> Q;
  28.     while (Q--)
  29.     {
  30.         fin >> i1 >> j1 >> i2 >> j2;
  31.         fout <<  s[i2][j2] - s[i1-1][j2] - s[i2][j1-1] + s[i1-1][j1-1] << '\n';
  32.     }
  33.  
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top