记录编号 196585 评测结果 AAAAAAAAAAAA
题目名称 [USACO Jan07]考试 最终得分 100
用户昵称 Gravatarlyxin65 是否通过 通过
代码语言 C++ 运行时间 0.015 s
提交时间 2015-10-21 21:33:06 内存使用 97.59 MiB
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fly(...) fprintf(stderr, __VA_ARGS__)

namespace io
{
	const int BZ = 100000005;
	char b[BZ], *i = b, *out = b;
	template<typename T>
	inline void read(T &x)
	{
		register int c; bool f = 0;
		while(c = *i++, c < '0' || c > '9') c == '-' ? f = 1 : 0;
		for(x = 0; c >= '0' && c <= '9'; c = *i++) x = (x << 1) + (x << 3) + c - '0';
		f ? x = -x : 0;
	}

	template<typename T>
	inline void write(T x, char ch = '\n')
	{
		static char s[20], *c = s; *c++ = ch;
		do *c++ = x % 10 + '0'; while(x /= 10);
		while(c - s) *out++ = *--c;
	}

	void input()
	{
		fread(b, 1, BZ, stdin);
	}

	void output()
	{
		fwrite(b, 1, out - b, stdout);
	}
}

using io::read;
using io::write;
using namespace std;

const int MAXN = 50005;

struct Point
{
	int x, y;

	inline void init() {
		read(y), read(x);
	}
	
	inline bool operator < (const Point &rhs) const {
		return y * rhs.x < x * rhs.y;
	}
};

inline Point operator - (const Point &a, const Point &b)
{
	return (Point){a.x - b.x, a.y - b.y};
}

inline int Cross(const Point &a, const Point &b)
{
	return a.x * b.y - a.y * b.x;
}

inline int Cross(const Point &a, const Point &b, const Point &c)
{
	return Cross(b - a, c - a);
}

double k;
#define getb(a) (a.y - k * a.x)

int n;
Point p[MAXN];
double G[MAXN];
double in[MAXN], out[MAXN];
int pos[MAXN];

void input()
{
	read(n);
	for(register int i = 1; i <= n; ++i)
		p[i].init();
}

void solve()
{
	sort(p + 1, p + n + 1);
	for(register int i = n - 1, x = 0, y = 0, tot = 0; i >= 1; --i)
	{
		x += p[i + 1].x, y += p[i + 1].y;
		k = G[i] = (double)y / x; //去掉了i个点
//		fly("%f\n", k);
		while(tot >= 1 && p[pos[tot]].x <= p[i + 1].x) tot--;
		while(tot >= 2 && Cross(p[pos[tot - 1]], p[i + 1], p[pos[tot]]) <= 0) tot--;
		pos[++tot] = i + 1;
		while(tot >= 2 && getb(p[pos[tot]]) >= getb(p[pos[tot - 1]])) tot--;
		in[i] = getb(p[pos[tot]]);

	}
	for(register int i = 1, tot = 0; i < n; ++i)
	{
		k = G[i];
		while(tot >= 1 && p[pos[tot]].x >= p[i].x) tot--;
		while(tot >= 2 && Cross(p[pos[tot - 1]], p[pos[tot]], p[i]) >= 0) tot--;
		pos[++tot] = i;
		while(tot >= 2 && getb(p[pos[tot]]) <= getb(p[pos[tot - 1]])) tot--;
		out[i] = getb(p[pos[tot]]);
	}
	
	register int cnt = 0;
	static int ans[MAXN];
	for(register int i = 1; i < n; ++i)
		if(in[i] < out[i]) ans[++cnt] = i;
//	for(register int i = 1; i < n; ++i)
//		fly("%f %f\n", in[i], out[i]);
	write(cnt);
	for(register int i = 1; i <= cnt; ++i)
		write(ans[i]);
}

int main()
{
	freopen("schul.in", "r", stdin);
	freopen("schul.out", "w", stdout);

	io::input();
	input();
	solve();
	io::output();

	fclose(stdin);
	fclose(stdout);
	return 0;
}