Before the computer room did not network to do this problem, with the analytic geometry to determine the intersection axis
#include <cmath> #include <cstdio> #include <cstring> #include <algorithm> #define N 500003# Define EPS 1e-8using namespace std;struct node {Double k, b;int ID;} line[n];int N, stack[n], top = 0;bool ans[n];inline b OOL CMP (node X, node Y) {if (Fabs (X.K-Y.K) < EPS) return x.b < Y.b;elsereturn x.k < Y.K;} inline double crossx (int X, int Y) {return (LINE[Y].B-LINE[X].B)/(LINE[X].K-LINE[Y].K);} inline void Insert (int x) {while (top) {if (Fabs (LINE[X].K-LINE[STACK[TOP]].K) < EPS)--top;elseif (CROSSX (x, Stack[to P]) <= CROSSX (Stack[top], stack[top-1]) && top > 1)--top;elsebreak;} Stack[++top] = x;} int main () {scanf ("%d\n", &n), for (int i = 1; I <= n; ++i) {scanf ("%lf%lf\n", &LINE[I].K, &line[i].b); line[i ].id = i;} Sort (line + 1, line + n + 1, CMP); for (int i = 1; I <= n; ++i) insert (i); for (int i = 1; I <= top; ++i) ans[line[stack[i ]].id] = 1;for (int i = 1; I <= n; ++i) if (Ans[i]) printf ("%d", I); return 0;}
Hhh
"Bzoj 1007" "Hnoi 2008" Horizontal linear analytic geometry