Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define fi first
- #define se second
- using namespace std;
- int n,i,w,x,y;
- vector < pair < pair < int , int > , pair < int ,int > > > all;
- long long res,first,secon;
- bool tmp(pair < pair < int , int > , pair < int , int > > A,pair < pair < int , int > , pair < int , int > > B) {
- if (1LL*A.fi.fi*B.fi.se < 1LL*A.fi.se*B.fi.fi) return true;
- if (1LL*A.fi.fi*B.fi.se > 1LL*A.fi.se*B.fi.fi) return false;
- return A.se<B.se;
- }
- int main() {
- cin>>n>>w;
- for (i=1;i<=n;i++) {
- scanf("%d%d",&x,&y);
- if (x < 0) {
- all.push_back({{-x,y+w},{0,1}});
- all.push_back({{-x,y-w},{1,1}});
- } else {
- all.push_back({{x,-y+w},{0,2}});
- all.push_back({{x,-y-w},{1,2}});
- }
- }
- sort(all.begin(),all.end(),tmp);
- for (i=0;i<all.size();i++) {
- if (all[i].se.se == 1 && all[i].se.fi == 0) {res+=secon;first++;}
- if (all[i].se.se == 2 && all[i].se.fi == 0) {res+=first;secon++;}
- if (all[i].se.se == 1 && all[i].se.fi == 1) first--;
- if (all[i].se.se == 2 && all[i].se.fi == 1) secon--;
- }
- cout<<res<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement