uva 11020 - Efficient Solutions ——平衡BST

时间:2023-03-08 17:32:41
uva 11020 - Efficient Solutions ——平衡BST

链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1961

训练指南page228

 #include <cstdio>
#include <set>
using namespace std;
struct Point
{
int a, b;
bool operator < (const Point & other) const
{
return (a < other.a) || (a == other.a && b < other.b);
}
};
multiset<Point> S;
multiset<Point>::iterator it;
int main(void)
{
#ifndef ONLINE_JUDGE
freopen("11020.in", "r", stdin);
#endif // ONLINE_JUDGE
int T; scanf("%d", &T);
for (int i = ; i <= T; ++i)
{
printf("Case #%d:\n", i); int n, a, b; scanf("%d", &n); S.clear();
while (n--)
{
scanf("%d%d", &a, &b); Point P = (Point){a, b}; it = S.lower_bound(P);
if (it == S.begin() || (--it)->b > b) S.insert(P), it = S.upper_bound(P);
while (it != S.end() && it->b >= b) S.erase(it++);
printf("%d\n", S.size());
}
if (i!=T) printf("\n");
}
return ;
}

。。

  本来想睡觉的,这题看了一半,还是做完吧,贴完睡觉。

  今天身体超级难受……好久没生过病了,没想到这么痛苦,o(╯□╰)o头疼,浑身上下都不舒服,下午去机房,那个难受啊,我去……赶紧回来了,晚上在综合楼还好一点,以后就住在综合楼和KFC和书院九号了。头晕,睡觉……

  对了,明天晚上跑步去,不去锻炼一下一点儿也没意思……什么毛病都出来了。。=_=

  晚安。