Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <algorithm>
- using namespace std;
- using ll = long long;
- set<pair<int,int>> cords;
- constexpr int INF = 1e9+7;
- pair<int,int> getK(pair<int, int> a, pair<int, int> b) {
- a.first -= b.first;
- a.second -= b.second;
- int g = __gcd(abs(a.first), abs(a.first));
- if (g != 0)
- {
- a.first /= g;
- a.second /= g;
- }
- //if (a.first == a.second && a.first==0)
- // return{INF, INF};
- if (a.first == 0)
- a.second = INF;
- if (a.second == 0)
- a.first = INF;
- return { a.first, a.second };
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- int n;
- cin >> n;
- pair<int, int> point;
- while(n--)
- {
- cin >> point.first >> point.second;
- cords.insert(point);
- }
- pair<int, int> k = getK(*cords.begin(), *cords.rbegin());
- int check = 0;
- auto el = ++cords.begin();
- while (el!=cords.end()) {
- if (k != getK(*cords.begin(), *el)) {
- check = 1;
- break;
- }
- el++;
- }
- check ? cout << "no" : cout << "yes";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement