Guest User

Untitled

a guest
Aug 25th, 2019
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. using namespace std;
  4.  
  5. struct Point{
  6. int x, y;
  7.  
  8. int getDir() {
  9. if (y > 0 && x > 0) {
  10. return 1;
  11. } else if (x == 0 && y > 0) {
  12. return 2;
  13. } else if (x < 0 && y > 0) {
  14. return 3;
  15. } else if (y == 0 && x < 0) {
  16. return 4;
  17. } else if (x < 0 && y < 0) {
  18. return 5;
  19. } else if (x == 0 && y < 0) {
  20. return 6;
  21. } else if (x > 0 && y < 0) {
  22. return 7;
  23. } else if (y == 0 && x > 0) {
  24. return 8;
  25. } else if (x == 0 && y == 0) {
  26. return 0;
  27. }
  28. }
  29. };
  30.  
  31. ll distance (Point first, Point second) {
  32. ll x = first.x - second.x;
  33. ll y = first.y - second.y;
  34. return x * x + y * y;
  35. }
  36.  
  37. int main() {
  38. int n;
  39. cin >> n;
  40.  
  41. vector<Point> have(n);
  42.  
  43. for (int i = 0; i < n; i++)
  44. cin >> have[i].x >> have[i].y;
  45.  
  46. ll ans = 0;
  47. for (int i = 0; i < n; i++) {
  48. vector<pair<ll, int>> dist;
  49. for (int j = 0; j < n; j++) {
  50. if (i != j)
  51. dist.push_back({distance(have[i], have[j]), have[j].getDir()});
  52. }
  53.  
  54. int j = 0;
  55. while (j < dist.size()) {
  56. int q = 0, s = 0;
  57. ll last = dist[j].first;
  58.  
  59. while (j < dist.size() && dist[j].first == last) {
  60. q++;
  61. j++;
  62. }
  63.  
  64. int dir = have[i].getDir();
  65. for (int k = 1; k < j; k++) {
  66. int ff = dist[k].second;
  67. int ss = dist[k - 1].second;
  68.  
  69. if (dist[k].first == dist[k - 1].first && ((dir == ff && dir == ss && ff == ss) || abs(ff - ss) == 4 || (ss == 0 && (ff == 2 || ff == 4 || ff == 6 || ff == 8)))) {
  70. s++;
  71. }
  72. }
  73. ans += q * (q - 1) / 2 - s;
  74. }
  75. }
  76.  
  77. cout << ans << "\n";
  78. }
RAW Paste Data