SHARE
TWEET

Untitled

a guest Oct 20th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <map>
  5. #include <set>
  6. #include <string>
  7. #include <vector>
  8. #include <queue>
  9. #include <stack>
  10. #include <deque>
  11. #include <math.h>
  12.  
  13.  
  14. #define mp make_pair
  15. #define pb push_back
  16. #define super_power_ON ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  17. #define pii pair<long long, long long>
  18. #define all(a) a.begin(), a.end()
  19. #define BigPair pair <pair <long long, long long>, pair <long long, long long>>
  20. #define rt return
  21. #define ll long long
  22. #define X first
  23. #define Y second
  24.  
  25. using namespace std;
  26.  
  27. ll gcd(ll a, ll b) {
  28.     a = abs(a);
  29.     b = abs(b);
  30.     while (a != 0 && b != 0) {
  31.         if (a < b) {
  32.             swap(a, b);
  33.         }
  34.         a %= b;
  35.     }
  36.     if (a == 0) {
  37.         return b;
  38.     }
  39.     else {
  40.         return a;
  41.     }
  42. }
  43.  
  44.  
  45. vector<pair<int, int>> p;
  46. int n;
  47. ll ans = 0;
  48.  
  49. int main() {
  50.     super_power_ON;
  51.     cin >> n;
  52.     for (int i = 1; i <= n; i++) {
  53.         int x, y;
  54.         cin >> x >> y;
  55.         p.push_back(make_pair(x, y));
  56.     }
  57.  
  58.     for (int cur = 0; cur < n; cur++) {
  59.         map<pair<int, int>, ll> kol_vo;
  60.         for (int i = 0; i < n; i++) {
  61.             if (i == cur) {
  62.                 continue;
  63.             }
  64.             pair<ll, ll> vec = make_pair(p[i].X - p[cur].X, p[i].Y - p[cur].Y);
  65.             ll g = gcd(vec.X, vec.Y);
  66.             vec = make_pair(vec.X / g, vec.Y / g);
  67.             if (vec.first == 0) {
  68.                 vec = make_pair(0, abs(vec.Y));
  69.             }
  70.             if (vec.first < 0) {
  71.                 vec = make_pair(-vec.X, -vec.Y);
  72.             }
  73.             kol_vo[vec]++;
  74.         }
  75.  
  76.         for (auto cur_ : kol_vo) {
  77.             pair<ll, ll> vec = cur_.X;
  78.             pii normal_v = make_pair(-vec.Y, vec.X);
  79.             ll cnt = cur_.Y;
  80.             if (normal_v.X == 0) {
  81.                 normal_v = make_pair(0, abs(normal_v.Y));
  82.             }
  83.             if (normal_v.X < 0) {
  84.                 normal_v = make_pair(-normal_v.X, -normal_v.Y);
  85.             }
  86.             if (kol_vo.find(normal_v) != kol_vo.end()) {
  87.                 ans += kol_vo[normal_v] * cnt;
  88.             }
  89.         }
  90.     }
  91.     cout << ans / 2;
  92. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top