标签:class tmp opera oid begin || ini back 基本
#include<stdio.h> #include <vector> #include <algorithm> using namespace std; const int maxn=1e5+10; struct point{ double x,y; void in() { scanf("%lf%lf",&x,&y); } inline point f(point a)const{ if(a.x<=0&&a.y>=0) a.x=-a.x,a.y=-a.y; return a; } double operator <(const point &a)const { return f(*this)*f(a)>0; } double operator*(const point &a)const { return x*a.y-y*a.x; } void out() { printf("%f %f\n",x,y); } }; int same=0,biger=0,tmp=0; vector<point>q; void init() { int n; scanf("%d",&n); double x,y; scanf("%lf%lf",&x,&y); point t; for(int i=1;i<n;i++) { t.in(); t.x-=x;t.y-=y; if(!t.x&&!t.y) same++; else if(t.x>0&&t.y>0) biger++; else if(t.x<0&&t.y<0); else { q.push_back(t); if(t.x>=0&&t.y<=0) tmp++; //4th quadrant } } } void solve() { sort(q.begin(),q.end()); //把排序做好就基本上没问题了 // for(auto i:q) // i.out(); // printf("%d\n",q.size()); int mx=0,mn=biger+tmp; for(int i=0,j,sz=q.size();i<sz;i=j) { int l=0,r=0; for(j=i;j<sz&&q[j]*q[i]==0;j++) { if(q[j].y>0||q[j].y==0&&q[j].x<0) l++; else r++; } // printf("%d %d %d %d\n",i,j,l,r); mx=max(mx,biger+same+tmp+l); mn=min(mn,biger+tmp-r); tmp+=l-r; } printf("%d %d\n",mn+1,mx+1); } int main() { // freopen("in.txt","r",stdin); init(); solve(); return 0; }
Codeforces Gym 101174 B Within Arm's Reach 极角排序
标签:class tmp opera oid begin || ini back 基本
原文地址:https://www.cnblogs.com/polya/p/9711041.html