题目描述:
The cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessie, ever the competent travel agent, has named the Bullmoose Hotel on famed Cumberland Street as their vacation residence. This immense hotel has N ( 1 ≤ N ≤ 50 , 000 ) N (1 \leq N \leq 50,000) N(1≤N≤50,000) rooms all located on the same side of an extremely long hallway (all the better to see the lake, of course).
The cows and other visitors arrive in groups of size D i ( 1 ≤ D i ≤ N ) Di (1 \leq D_i \leq N) Di(1≤Di≤N) and approach the front desk to check in. Each group i requests a set of Di contiguous rooms from Canmuu, the moose staffing the counter. He assigns them some set of consecutive room numbers r . . . r + D i − 1 r...r+D_i-1 r...r+Di−1 if they are available or, if no contiguous set of rooms is available, politely suggests alternate lodging. Canmuu always chooses the value of r to be the smallest possible.
Visitors also depart the hotel from groups of contiguous rooms. Checkout i has the parameters X i X_i Xi and D i D_i Di which specify the vacating of rooms X i . . . X i + D i − 1 ( 1 ≤ X i ≤ N − D i + 1 ) X_i ...X_i +D_i-1 (1 \leq X_i \leq N-D_i+1) Xi...Xi+Di−1(1≤Xi≤N−Di+1). Some (or all) of those rooms might be empty before the checkout.
Your job is to assist Canmuu by processing M ( 1 ≤ M ≤ 50 , 000 ) M (1 \leq M \leq 50,000) M(1≤M≤50,000) checkin/checkout requests. The hotel is initially unoccupied.
参考样例,第一行输入 n n n, m m

这篇博客介绍了USACO08FEB竞赛中的题目Hotel G,涉及到的问题是在酒店房间分配中使用线段树来处理入住和退房请求。文章详细阐述了线段树的数据结构维护,包括节点信息、区间最大连续空房间的维护以及lazy标记的上下推更新策略。最后给出了AC代码实现。
最低0.47元/天 解锁文章

111

被折叠的 条评论
为什么被折叠?



