[Solution] Intersection and Union Codeforces Solution
You are given segments on the coordinate axis. The -th segment is . Let's denote the set of all integer points belonging to the -th segment as .
Let be the union of two sets and , be the intersection of two sets and , and be the symmetric difference of and (a set which contains all elements of and all elements of , except for the ones that belong to both sets).
Let be an array where each element is either , , or . Over all ways to choose this array, calculate the sum of the following values:
In this expression, denotes the size of the set .
The first line contains one integer ().
Then, lines follow. The -th of them contains two integers and ().
Print one integer — the sum of over all possible ways to choose . Since the answer can be huge, print it modulo .
No comments:
Post a Comment