传送门:https://loj.ac/problem/516 [题解] 那段代码求的是相同的数中间隔最小的值. 离散后用set维护每个值出现次数,每次操作相当于合并两个set,这步可以启发式合并. 加元素的时候直接找前驱和后继即可. 学了新姿势:set中insert有返回的,可以访问.first来调用新插入元素的iterator # include <set> # include <vector> # include <stdio.h> # include <st…
Coach Pang and Uncle Yang both love numbers. Every morning they play a game with number together. In each game the following will be done: 1. Coach Pang randomly choose a integer x in [a, b] with equal probability. 2. Uncle Yang randomly choose a i…