fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main(){
  6. int T, N, lowerX, higherX, lowerY, higherY, test;
  7. cin >> T;
  8.  
  9. for (int i = 1; i <= T; ++i)
  10. {
  11. cin >> N >> lowerX >> lowerY >> higherX >> higherY;
  12.  
  13. for (int j = 2; j <= N; ++j)
  14. {
  15. cin >> test;
  16. if (test>lowerX)
  17. {
  18. lowerX = test;
  19. }
  20. //////////////////////////////////////
  21. if (test>=higherX)
  22. {
  23. higherX = lowerX;
  24. break;
  25. }
  26. //////////////////////////////////////
  27. cin >> test;
  28. if (test>lowerY)
  29. {
  30. lowerY = test;
  31. }
  32. cin >> test;
  33. if (test<higherX)
  34. {
  35. higherX = test;
  36. }
  37. /////////////////////////////////////
  38. if (test<=lowerX)
  39. {
  40. lowerX = higherX;
  41. break;
  42. }
  43. /////////////////////////////////////
  44. cin >> test;
  45. if (test<higherY)
  46. {
  47. higherY = test;
  48. }
  49. }
  50.  
  51.  
  52. cout << "Case #" << i << ": " << abs(higherX-lowerX)*abs(higherY-lowerY) << "\n";
  53.  
  54. }
  55.  
  56.  
  57. return 0;
  58. }
Success #stdin #stdout 0.01s 5316KB
stdin
2
2
0 0 1 1
1 1 2 2
2
0 0 1 1
2 2 3 3
stdout
Case #1: 0
Case #2: 0