这个题半平面交很显然了,都直接给出直线了有木有!!??答案就是交出来的(分段函数)凸壳有几块就行。。有相等什么的情况特别恶心。
然而本蒟蒻直接上的模板还是错了。。。跪(不知道为什么)
1 /*#include2 #define N 100005 3 #define LL long long 4 #define eps 1e-8 5 #define double long double 6 using namespace std; 7 inline int ra() 8 { 9 int x=0,f=1; char ch=getchar(); 10 while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();} 11 while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();} 12 return x*f; 13 } 14 const double inf=1e15; 15 int n,cnt,tot,L,R,ans[N],num,orz; 16 struct data_in{int k,b; int id;}q[N]; 17 struct point{double x,y;}; 18 struct line{ 19 point a,b; double angle; int id; 20 void print(){ 21 printf("%.1lf %.1lf %.1lf %.1lf\n",a.x,a.y,b.x,b.y); 22 } 23 }l[N],s[N]; 24 double operator * (point a, point b){ 25 return a.x*b.y-a.y*b.x; 26 } 27 point operator - (point a, point b){ 28 point t; t.x=a.x-b.x; t.y=a.y-b.y; return t; 29 } 30 bool operator < (line a, line b){ 31 if (a.angle==b.angle) return (b.b-a.a)*(a.b-a.a)>=0; 32 return a.angle 109 #include 110 #define N 100005111 #define eps 1e-8112 using namespace std;113 int n,top;114 int ans[N];115 struct line{116 int k,b,id;117 friend bool operator < (line a, line b){118 if (a.k==b.k) return a.b inter(a,t);128 }129 int main()130 {131 scanf("%d",&n);132 for (int i=1; i<=n; i++) scanf("%d",&c[i].b);133 for (int i=1; i<=n; i++) scanf("%d",&c[i].k);134 for (int i=1; i<=n; i++) c[i].id=i;135 sort(c+1,c+n+1); top=1;136 for (int i=2; i<=n; i++)137 {138 if (c[i].k!=c[i-1].k || (c[i].k==c[i-1].k && c[i].b==c[i-1].b))139 top++;140 c[top]=c[i];141 }142 n=top; top=0;143 q[++top]=c[1]; ans[1]=c[1].id;144 for (int i=2; i<=n; i++)145 {146 while (top>=1 && inter(q[top],c[i])<-eps) top--;147 while (top>=2 && jud(q[top-1],q[top],c[i])) top--;148 q[++top]=c[i]; ans[top]=c[i].id;149 }150 printf("%d\n",top);151 sort(ans+1,ans+top+1);152 for (int i=1; i<=top; i++)153 {154 printf("%d",ans[i]);155 if (i!=top) printf(" ");156 }157 // while (1);158 return 0;159 }