A Few Randomization Problems
Difficulty Ratings
Idea Creativity: 3/5(Some are pretty geniosity)Techniques Used: 2/5
Implementation : 2/5
Resources
Uh, there is not much techniquees in Randomization. But basically you must know Blogewoosh #6 trick.Task 1
Simplified Statement
CF 1240E Note: This problem is not easy at all.Solution
Read the editorial lol. The key to optimize from two logs to one log is to use blogewoosh trick, which is kinda surprise to me(?)...Task 2
By alex20030190Simplified Statement
Given a permutation A of length $N \le 100000$ and an array B, sum $f(l,r)$ for all pairs of $1 \le l \le r \le N$, where $f(l,r) = M1(l,r) \times M2(l,r) \times B[r-l+1]$, and $M1(l,r)$, $M2(l,r)$ means the maximum and second maximum in $A[l..r]$ respectively. It is guarenteed that A is randomly generated.Solution
It is quite geniosity. The solution is to pick the maximum of array, compute sum for all ranges that included the value, then divide and conquer. The complexity analysis is similar to quick sort.Task 3
Problem Link
Link in simplified chinese by jiry_2Simplified Statement
Maintain an array of length $N \le 100000$ with $Q \le 1000000$ updates and queries. Initially, each value of the array is a random number which is in $[0,100000]$.There are three types of operations:
C: Generate random by given seed $p,y$, and set $A[p]=y$. $y$ is in $[0,100000]$.
R: Generate random by given seed $l,r$, swap if $l \gt r$, and set $A[p]=100000-A[p]$ for all $p$ inside $[l,r]$.
Q a b c: Generate random by given seed $l,r$, swap if $l \gt r$, and find the maximum value of $a \times p + b \times A[p] + c \times p \times A[p]$, where p is inside $[l,r]$.
wow
回覆刪除Thanks! Nice methods!
回覆刪除