fork download
  1. #define _CRT_SECURE_NO_DEPRECATE
  2. #include <iostream>
  3. #define MAX 110
  4. using namespace std;
  5. int n, m, t, k;
  6.  
  7. struct Point {
  8. int x;
  9. int y;
  10. }p[MAX];
  11.  
  12. void input() {
  13. int i;
  14. cin >> n >> m >> t >> k;
  15. for (i = 0; i < t; i++) {
  16. cin >> p[i].x >> p[i].y;
  17. }
  18. }
  19.  
  20. void run() {
  21. int i, j, q, X, Y, count = 0, max = 0, ax, ay;
  22.  
  23. for (i = 0; i < t; i++) {
  24. for (j = 0; j < t; j++) {
  25. X = p[i].x;
  26. Y = p[j].y;
  27. for (q = 0; q < t; q++) {
  28. if (X <= p[q].x && p[q].x <= X + k && Y <= p[q].y && p[q].y <= Y + k) {
  29. count++;
  30. }
  31. }
  32.  
  33. if (max <= count) {
  34. max = count;
  35. ax = X;
  36. ay = Y;
  37. }
  38. count = 0;
  39. }
  40. }
  41.  
  42. cout << ax << " " << ay + k << endl;
  43. cout << max;
  44. }
  45.  
  46. int main() {
  47. //freopen("input.txt", "r",stdin);
  48. input();
  49. run();
  50.  
  51.  
  52. }
Success #stdin #stdout 0s 15240KB
stdin
10 6 7 3
2 2
3 4
7 6
4 5
4 3
5 3
6 4
stdout
4 6
5