fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. #define MAX_N 100
  7. #define INF 100000000
  8.  
  9. int Answer;
  10.  
  11. struct point {
  12. int x, y;
  13. };
  14.  
  15. int abs(int a, int b) {
  16. if (a < b) return b - a;
  17. else return a - b;
  18. }
  19.  
  20. int dist(point p1, point p2) {
  21. return max(abs(p1.x, p2.x), abs(p1.y, p2.y));
  22. }
  23.  
  24. int powerdist(point p, point line[]) {
  25. return min(dist(p, line[0]), dist(p, line[1]));
  26. }
  27.  
  28. int N;
  29. struct point line[MAX_N][2];
  30.  
  31. int main(int argc, char** argv)
  32. {
  33. int T, test_case;
  34.  
  35. cin >> T;
  36. for (test_case = 0; test_case < T; test_case++)
  37. {
  38. Answer = 0;
  39. cin >> N;
  40. for (int n = 0; n < N; n++) {
  41. cin >> line[n][0].x >> line[n][0].y >> line[n][1].x >> line[n][1].y;
  42. }
  43.  
  44. for (int n = 0; n < N; n++) {
  45. int dist0 = -1, dist1 = -1;
  46. for (int m = 0; m < N; m++) {
  47. dist0 = max(dist0, powerdist(line[n][0], line[m]));
  48. dist1 = max(dist1, powerdist(line[n][1], line[m]));
  49. }
  50. Answer = max(Answer, min(dist0, dist1));
  51. }
  52.  
  53. cout << "Case #" << test_case + 1 << endl;
  54. if (Answer % 2) cout << Answer/2 << ".5" << endl;
  55. else cout << Answer / 2 << endl;
  56. }
  57.  
  58. return 0;
  59. }
Success #stdin #stdout 0s 5516KB
stdin
3
2
1 1 10 1
4 2 5 2
8
3 6 3 10
4 7 10 7
7 2 7 9
11 1 11 10
1 5 13 5
4 3 8 3
2 2 4 2
9 2 15 2
8
3 6 3 10
4 7 10 7
7 2 7 9
11 1 11 10
1 5 15 5
4 3 8 3
2 2 4 2
9 2 15 2
stdout
Case #1
1.5
Case #2
5
Case #3
5