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.

60 lines
3.1 KiB
Markdown

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 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
[正版题解](http://codeforces.com/blog/entry/49160)
> 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 is*l*and right end of the segment is*r*. Let the set of songs with partly time is*half*and 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 to*half*) 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 than*k*we are not allowed to move*r*. 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 from*full*, subtract from total time length of this song. In the other case we delete it from*half*and subtract from the total time the$(t_r+1)/2$. After that we try to take some song from*full*. If the size of*full*is 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了