Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <algorithm>
- #include <map>
- #include <set>
- #include <string>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <deque>
- #include <math.h>
- #define mp make_pair
- #define pb push_back
- #define super_power_ON ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define pii pair<long long, long long>
- #define all(a) a.begin(), a.end()
- #define BigPair pair <pair <long long, long long>, pair <long long, long long>>
- #define rt return
- #define ll long long
- #define X first
- #define Y second
- using namespace std;
- ll gcd(ll a, ll b) {
- a = abs(a);
- b = abs(b);
- while (a != 0 && b != 0) {
- if (a < b) {
- swap(a, b);
- }
- a %= b;
- }
- if (a == 0) {
- return b;
- }
- else {
- return a;
- }
- }
- vector<pair<int, int>> p;
- int n;
- ll ans = 0;
- int main() {
- super_power_ON;
- cin >> n;
- for (int i = 1; i <= n; i++) {
- int x, y;
- cin >> x >> y;
- p.push_back(make_pair(x, y));
- }
- for (int cur = 0; cur < n; cur++) {
- map<pair<int, int>, ll> kol_vo;
- for (int i = 0; i < n; i++) {
- if (i == cur) {
- continue;
- }
- pair<ll, ll> vec = make_pair(p[i].X - p[cur].X, p[i].Y - p[cur].Y);
- ll g = gcd(vec.X, vec.Y);
- vec = make_pair(vec.X / g, vec.Y / g);
- if (vec.first == 0) {
- vec = make_pair(0, abs(vec.Y));
- }
- if (vec.first < 0) {
- vec = make_pair(-vec.X, -vec.Y);
- }
- kol_vo[vec]++;
- }
- for (auto cur_ : kol_vo) {
- pair<ll, ll> vec = cur_.X;
- pii normal_v = make_pair(-vec.Y, vec.X);
- ll cnt = cur_.Y;
- if (normal_v.X == 0) {
- normal_v = make_pair(0, abs(normal_v.Y));
- }
- if (normal_v.X < 0) {
- normal_v = make_pair(-normal_v.X, -normal_v.Y);
- }
- if (kol_vo.find(normal_v) != kol_vo.end()) {
- ans += kol_vo[normal_v] * cnt;
- }
- }
- }
- cout << ans / 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement