Advertisement
limimage

TASK A

May 26th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. using ll = long long;
  7. set<pair<int,int>> cords;
  8. constexpr int INF = 1e9+7;
  9.  
  10. pair<int,int> getK(pair<int, int> a, pair<int, int> b) {
  11. a.first -= b.first;
  12. a.second -= b.second;
  13. int g = __gcd(abs(a.first), abs(a.first));
  14. if (g != 0)
  15. {
  16. a.first /= g;
  17. a.second /= g;
  18. }
  19. if (a.first == a.second && a.first==0)
  20. return{INF, INF};
  21. if (a.first == 0)
  22. a.second = 1;
  23. if (a.second == 0)
  24. a.first = 1;
  25. return { a.first, a.second };
  26. }
  27.  
  28. int main() {
  29. ios_base::sync_with_stdio(false);
  30. cin.tie(nullptr);
  31.  
  32. int n;
  33. cin >> n;
  34. pair<int, int> point;
  35. while(n--)
  36. {
  37. cin >> point.first >> point.second;
  38. cords.insert(point);
  39. }
  40. pair<int, int> k = getK(*cords.begin(), *cords.rbegin());
  41. int check = 0;
  42. for (auto el: cords) {
  43. if (k != (getK(*cords.begin(), el)==make_pair(INF, INF)?k:getK(*cords.begin(), el))) {
  44. check = 1;
  45.  
  46. break;
  47. }
  48. }
  49. check ? cout << "no" : cout << "yes";
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement