1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
   | #include<cstdio> #include<cstring> #include<algorithm> #define RG register #define clear(x, y) memset(x, y, sizeof(x));
  inline int read() { 	int data = 0, w = 1; 	char ch = getchar(); 	while(ch != '-' && (ch < '0' || ch > '9')) ch = getchar(); 	if(ch == '-') w = -1, ch = getchar(); 	while(ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar(); 	return data*w; }
  const int maxn(3e5 + 10); int q[maxn], top, next[maxn], ok[maxn], n; struct point { int x, y, id; } p[maxn]; double k[maxn]; inline bool operator < (const point &lhs, const point &rhs) { 	return lhs.x > rhs.x || (lhs.x == rhs.x && lhs.y > rhs.y); }
  inline double slope(const point &i, const point &j) { 	return 1. * i.x * j.x * (j.y - i.y) / (1. * i.y * j.y * (j.x - i.x)); }
  int main() { 	n = read(); int minx, miny = 0; 	for(RG int i = 1; i <= n; i++) 	{ 		p[i] = (point) {read(), read(), i}; 		if(miny < p[i].y || (miny == p[i].y && minx < p[i].x)) 			minx = p[i].x, miny = p[i].y; 	}
  	std::sort(p + 1, p + n + 1); 	q[top = 1] = 1; 	for(RG int i = 2; i <= n && minx <= p[i].x; i++) 	{ 		if(p[q[top]].x == p[i].x) 		{ 			if(p[q[top]].y == p[i].y) 				next[p[i].id] = next[p[q[top]].id], next[p[q[top]].id] = p[i].id; 			continue; 		}
  		while(top > 1 && k[top] > slope(p[q[top]], p[i])) --top; 		q[++top] = i; k[top] = slope(p[q[top - 1]], p[i]); 	}
  	for(RG int i = top; i; --i) 		for(RG int j = p[q[i]].id; j; j = next[j]) ok[j] = 1; 	for(RG int i = 1; i <= n; i++) if(ok[i]) printf("%d ", i); 	return 0; }
   |