fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #define N 100
  4. using namespace std;
  5.  
  6. int main() {
  7. int rect[3][4];
  8. int field[2*N][2*N];
  9. int count = 0;
  10. for(int i = 0;i<2*N;i++)for(int k = 0;k<2*N;k++)field[i][k]=0;
  11. for(int i = 0;i<3;i++){
  12. for(int k = 0;k<4;k++){
  13. cin>>rect[i][k];
  14. rect[i][k]=rect[i][k]+N;
  15. }
  16. }
  17. for(int k = 0;k<3;k++){
  18. for(int i = min(rect[k][0],rect[k][2]);i<max(rect[k][0],rect[k][2]);i++){
  19. for(int j = min(rect[k][1],rect[k][3]);j<max(rect[k][1],rect[k][3]);j++){
  20. field[i][j]=1;
  21. }
  22. }
  23. }
  24. for(int i = 0;i<2*N;i++){
  25. for(int k = 0;k<2*N;k++){
  26. if(field[i][k]==1)count++;
  27. }
  28. }
  29. cout<<count;
  30. }
Success #stdin #stdout 0s 15264KB
stdin
0 0 0 0
-1 -1 2 2
-9 -9 1 1
stdout
105