You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.3 KiB

CUGACM2019寒假作业-- 灵活使用STL

A - 水果

map<string, map<string, int>> 模拟即可

B - Hacker, pack your bags!

对于每一天维护这一天之前结束的相同时长的所有旅程中cost最小的不然暴力会TLE。

C - The Union of k-Segments

前缀和瞎搞搞就可以了。

D - Sockets

将电脑连同id一起扔进multimap里然后对socket排序从最小的开始这是个什么神奇道理检查是否有符合的电脑如果没有就(x+1)/2直到找到这样的电脑或比当前最小电脑所用量还小其实直接循环个31次应该也能过

E - Bipartite Graph

首先已知这是一个二分图,将其染色并统计两部分数量。将孤立的点选择加到集合一还是二,取最大值即可,时间复杂度与输入复杂度相同。

F - Pearls in a Row

拿set随便一搞就过了注意Codeforces默认是32位编译的。实在拿不定怎么输出就cout吧

G - Kiki & Little Kiki 1

multiset.upper_bound()

H - 传递

题意看起来非常奇怪但是实际上只要用bitset存一下一个点连向了哪些点即可。只要保证对于每一条边其终点所连向的点的集合为起点连向的点的集合的子集即可判断这个图是“传递”的。

I - HDU Today

map/unordered_map+单源最短路

J - Counter Strike

转换为减掉平均值后求出的前缀和的顺序对数。

K - 区间交

说实话,没怎么看懂题解。望大佬们不吝告知。

L - Music in Car

正版题解

This problem can be solved with help of two pointers. We will store two sets — set with songs with full time and set with songs with partly time. How to move left and right pointers and recalculate current answer? Let left end of the current segment island right end of the segment isr. Let the set of songs with partly time ishalfand with full time —full. In this sets we will store pairs — time of listening each song and it number.

Right end we will move in the following way: if we can add partly song and we have enough time to listen it — we take it (also add this song tohalf) and add to time$(t_r+1)/2$and add to the answer$a_r$. In the other case we have two cases. First — we add current song as full song, second — we add current song as partly song. Here we need to choose case with less with the total time. Also here we need to correctly add song to sets and update total time and the answer. If total time became more thankwe are not allowed to mover. Now we need to update global answer with the current value of answer.

Left end we will move in the following way: if we took song as full song we delete it fromfull, subtract from total time length of this song. In the other case we delete it fromhalfand subtract from the total time the$(t_r+1)/2$. After that we try to take some song fromfull. If the size offullis 0, we can not do that. If we done it we need to change total time on the songs on the current segment.

M - Alice and Bob

multiset搞一下又忘记clear了

N - Moo University - Financial Aid

按成绩排序后用两个堆分别维护每头牛前后花钱最少的n/2头牛,逆序扫一遍即可。

辣鸡poj不让用bits/stdc++.h