Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 52328 Accepted: 24551 Case Time Limit: 2000MS Description For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer Joh…
CF1039D You Are Given a Tree LG传送门 根号分治好题. 这题可以整体二分,但我太菜了,不会. 根号分治怎么考虑呢?先想想\(n^2\)暴力吧.对于每一个要求的\(k\),一遍dfs直接贪心,能拼成链就直接拼,正确性不用我证明吧. 考虑对于\(k \le \sqrt n\),直接按照暴力去做,复杂度\(O(n \sqrt n)\):对于\(k\)从\(\sqrt n+1\)到\(n\)的所有情况,我们发现答案只会在\(\sqrt n\)到\(0\)之间取值(\(k>…
xor There is a tree with nn nodes. For each node, there is an integer value a_iai, (1 \le a_i \le 1,000,000,0001≤ai≤1,000,000,000 for 1 \le i \le n1≤i≤n). There is qq queries which are described as follow: Assume the value on the path from node…