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 = 1;
- if (a.second == 0)
- a.first = 1;
- 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;
- for (auto el: cords) {
- if (k != (getK(*cords.begin(), el)==make_pair(INF, INF)?k:getK(*cords.begin(), el))) {
- check = 1;
- break;
- }
- }
- check ? cout << "no" : cout << "yes";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement