Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define FINAL_OUT(x) {cout << x << '\n'; return 0;}
- int sign(long long x)
- {
- if (x > 0) return 1;
- if (x < 0) return -1;
- return 0;
- }
- int vector_prod(pair<int,int> a, pair<int,int> b)
- {
- return sign(a.first * 1LL * b.second - a.second * 1LL * b.first);
- }
- int scalar_prod(pair<int,int> a, pair<int,int> b)
- {
- return sign(a.first * 1LL * b.first + a.second * 1LL * b.second);
- }
- int main()
- {
- int xs,ys,xt,yt;
- cin >> xs >> ys >> xt >> yt;
- pair<int,int> need(xt - xs, yt - ys);
- if (need == make_pair(0,0))
- FINAL_OUT("YES");
- int n = 0;
- cin >> n;
- vector<pair<int,int> > a(n);
- for(int i = 0; i < n; ++i)
- cin >> a[i].first >> a[i].second;
- for(int i = 0; i < n; ++i)
- for(int j = 0; j < n; ++j)
- if (vector_prod(a[i], need) == 0)
- {
- if (scalar_prod(a[i], need) > 0)
- FINAL_OUT("YES");
- }
- else
- {
- if (vector_prod(a[i], a[j]) == vector_prod(a[i], need) && vector_prod(a[i], need) == vector_prod(need, a[j]))
- FINAL_OUT("YES");
- }
- FINAL_OUT("NO");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement