Advertisement
lalalalalalalaalalla

Untitled

Jun 26th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iomanip>
  5. #include <queue>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <tuple>
  9. #include <iomanip>
  10. #include <stdio.h>
  11. #include <numeric>
  12. #include <map>
  13. #include <math.h>
  14.  
  15. #define int long long
  16. #define double double
  17. #define ull unsigned long long
  18. #define all(a) a.begin(), a.end()
  19. #define pii pair<int, int>
  20. #define pb push_back
  21.  
  22. using namespace std;
  23.  
  24. pii correct(int x1, int y1, int x2, int y2, int x3, int y3) {
  25. if ((x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1) == 0) { // cos1 == 0 => 1 = 90 dg
  26. return {x2 + x3 - x1, y2 + y3 - y1};
  27. }
  28. if ((x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2) == 0) {
  29. return {x1 + x3 - x2, y1 + y3 - y2};
  30. }
  31. if ((x1 - x3) * (x2 - x3) + (y1 - y3) * (y2 - y3) == 0) {
  32. return {x1 + x2 - x3, y1 + y2 - y3};
  33. }
  34. return {101, 101};
  35. }
  36.  
  37. bool square(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
  38. int one, two, three, four;
  39. one = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
  40. two = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);
  41. three = (x4 - x3) * (x4 - x3) + (y4 - y3) * (y4 - y3);
  42. four = (x1 - x4) * (x1 - x4) + (y1 - y4) * (y1 - y4);
  43. // cout << one << " " << two << " " << three << " " << four << "\n";
  44. if (one == two and two == three and three == four and four == one) {
  45. return true;
  46. }
  47. return false;
  48. }
  49.  
  50. map<pair<int, int>, int> m;
  51.  
  52. signed main()
  53. {
  54. ios_base::sync_with_stdio(0);
  55. cin.tie(0);
  56. cout.tie(0);
  57. int n;
  58. cin >> n;
  59. vector<pair<int, int>> a(n);
  60. for (int i = 0; i < n; i++) {
  61. cin >> a[i].first >> a[i].second;
  62. m[a[i]] = 1;
  63. }
  64. int ans = 0;
  65. for (int i = 0; i < n - 2; i++) {
  66. for (int j = i + 1 ; j < n - 1; j++) {
  67. for (int k = j + 1; k < n; k++) {
  68. pair<int, int> v = correct(a[i].first, a[i].second, a[j].first, a[j].second, a[k].first, a[k].second);
  69. if (m[v]) {
  70. vector<pair<int, int>> q(4);
  71. q[0] = a[i];
  72. q[1] = a[j];
  73. q[2] = a[k];
  74. q[3] = v;
  75. sort(all(q));
  76. reverse(q.begin() + 2, q.end());
  77. if (square(q[0].first, q[0].second, q[1].first, q[1].second, q[2].first, q[2].second, q[3].first, q[3].second)) {
  78. ans++;
  79. }
  80. }
  81. }
  82. }
  83. }
  84. cout << ans / 4;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement