fork(3) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int ZERO = 1000;
  5. const int MAX = ZERO + 1 + ZERO;
  6.  
  7. bool CS[MAX][MAX];
  8. vector<pair<int, int>> P;
  9.  
  10. int main()
  11. {
  12. int n;
  13. cin >> n;
  14. while (n--) {
  15. int x, y;
  16. cin >> x >> y;
  17. x += ZERO;
  18. y += ZERO;
  19. CS[y][x] = true;
  20. P.emplace_back(x, y);
  21. }
  22. sort(P.begin(), P.end());
  23. int a = 0;
  24. for (int i = 0; i < (int)P.size(); ++i) {
  25. for (int j = i + 1; j < (int)P.size() && P[i].first == P[j].first; ++j) {
  26. int s = P[j].second - P[i].second;
  27. int x = P[i].first + s;
  28. if (x >= MAX) {
  29. break;
  30. }
  31. int y1 = P[i].second;
  32. int y2 = P[j].second;
  33. if (CS[y1][x] && CS[y2][x]) {
  34. ++a;
  35. }
  36. }
  37. }
  38. cout << a << endl;
  39. return 0;
  40. }
Success #stdin #stdout 0s 19144KB
stdin
10
0 1
0 2
0 5
3 0
3 2
3 5
4 1
4 5
5 0
5 2
stdout
3