Sort by a from small to large and then use the stack to solve it.
--------------------------------------------------------------------
#include <bits/stdc++.h>using namespace std;typedef long Long ll;const int MAXN = 50009;struct L {int A, B, id;inline void Read (int p) {scanf ("%d%d", &a, &b);id = p;}BOOL Operator < (const L &o) Const {return A < O.A | | (A = = o.a && B > O.B);}} S[MAXN];int N, STA[MAXN], top = 0;bool ANS[MAXN];bool Check (int a, int b, int c) {return (LL) (S[b]. A-S[C]. A) * (S[b]. B-s[a]. B) >= (LL) (S[c]. B-S[B]. B) * (S[a]. A-S[B]. A);}int main () {scanf ("%d", &n);for (int i = 0; i < N; i++)S[i]. Read (i);sort (s, S + N);sta[top = 0] = 0;for (int i = 1; i < N; i++) {if (S[i]. A = = S[sta[top]]. A)continue;While (top && check (Sta[top-1], sta[top], i)) top--;Sta[++top] = i;}memset (ans, 0, sizeof ans);For (; ~top; top--)Ans[s[sta[top]].id] = true;for (int i = 0; i < N; i++)if (Ans[i]) printf ("%d", i + 1);puts ("");return 0;}
--------------------------------------------------------------------
1007: [HNOI2008] Horizontal visible line time limit: 1 Sec Memory Limit: 162 MB
Submit: 4676 Solved: 1725
[Submit] [Status] [Discuss] Description
There are n linear l1,l2 on the Xoy Cartesian plane,... Ln, if the Y value is positive infinity down, you can see a sub-segment of Li, it is said that Li is visible, otherwise li is covered.
For example, for a line:
L1:y=x; L2:y=-x; L3:y=0
Then L1 and L2 are visible, and L3 are covered.
gives a line of N, expressed as a form of y=ax+b (| a|,| b|<=500000), and the N line 22 does not coincide. Find all the visible lines.
Input
The first behavior n (0 < n < 50000), the next n-line input Ai,bi
Output
From small to large output visible line number, 22 is separated by a space, the last number must also have a space behind
Sample Input3
-1 0
1 0
0 0Sample Output1 2HINT
Source
Bzoj 1007: [HNOI2008] Horizontal visible line (computed geometry)