2017 USP Try-outs 题解
A
维护每个点,点权能取到的最小值。然后我们开始dfs,我们用当前所在的节点,更新他的邻居,点权能取到的最小值。
B
权值和为(n(n+1)/2),如果权值和为奇数,肯定不行。如果为偶数,我们需要选一些数字凑出(n(n+1)/4),从大到小扫一遍,能拿就拿。
C
- 对于每个位置(l),我们可以求出最小的(r),使得([l,r])之间有互质的数对。
- 随着(l)的增大,(r)一定会增大,因此我们可以考虑尺取。
- 在右端点进入和左端点退出的时候,我们尝试维护区间内不互质数对的个数(pair)。
- 对于(mu(x) eq0)的(x),我们用(cnt[x])维护,区间内有多少个数字的因子中有(x),然后,没进入一个右端点(r)时,那么每个(d|a[r] 且 mu(d) eq0且d eq1)的(d)对(pair)的贡献为(-mu(d)cnt[d]),把这个贡献加到(pair)里去,同理,退出一个又端点的时候,把这个贡献从(pair)中减去。
D
- 我们来求(x)最小与最大的端点。
- 两条直线的交点的横坐标为(frac{m_1-m_2}{b_1-b_2})
- 对(b)排序且离散化后,(b_1,b_2)的位置,恰好相差一位。
E
- 样例看不懂,很令人狂躁
- 先把每个人的时间,从小到大排序。
- 用(dp[i])表示前(i)个人到达终点的最小耗时。
- 考虑(dp[i])如何求得,我们可以让(1)把(i)带过去,然后(1)回来。也可以(1)和(2)过去,然后(1)回来,然后(i)和(i-1)过去,然后(2)回来。
F
- 签到题,然后一堆WA
G
- 我怎么觉得这题和A一模一样啊
H
- 模拟
I
- 正解当然是网络流啦。2008NOI志愿者招募。
- 但非整数的线性规划居然能过。
J
- 数位DP,(dp[i][j][0/1])表示前(i-1)位放好了,之后放的数字和为(j)的方案数。
K
- 签到题
L
- 我们用(dp[i][j])来表示,让
s.substr(1,i)
成为t.substr(1,j)
的后缀的最小耗费。