fork(4) download
  1. #include <iostream>
  2. using namespace std;
  3. int mat[1001][1001];
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int q; cin >> q;
  8. while (q--) {
  9. int x1, y1, x2, y2;
  10. cin >> x1 >> y1 >> x2 >> y2;
  11. mat[x1][y1]++;
  12. mat[x2 + 1][y2 + 1]++;
  13. mat[x1][y2 + 1]--;
  14. mat[x2 + 1][y1]--;
  15. }
  16. for(int i=1;i<=n;i++,cout<<endl)
  17. for (int j = 1; j <= n; j++) {
  18. mat[i][j] += mat[i - 1][j] + mat[i][j - 1] - mat[i - 1][j - 1];
  19. cout << mat[i][j] << " ";
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 4268KB
stdin
5
4
2 2 4 4
2 2 4 4
1 1 2 2
1 1 5 5
stdout
2 2 1 1 1 
2 4 3 3 1 
1 3 3 3 1 
1 3 3 3 1 
1 1 1 1 1