Compress all Subsegments SOLUTIONS SEGCOMPR

Compress all Subsegments SOLUTIONS OCTOBER CHALLENGE 2020

For the array B, while it has more than one element, you can choose arbitrary two elements x,y (they may be the same, but they should have different indices) delete them, and add an element g(x,y) instead. Where g(x,y) denotes the highest bit in x⊕y, or 0 if they are equal. For example, g(1,1)=0,g(1,2)=2,g(2,4)=4,g(13,17)=16. In other words, g(x,y)=max2k, such that 2k≤(x⊕y) for x≠y, and g(x,y)=0 if x=y.
Let’s denote as f(B) the smallest possible value of the element if only one element left in B.
You are given an array A with N elements, you need to find the sum of F(Al…r) among all subsegments 1≤l≤r≤N.
The answer may be large, so you need to find it modulo 998244353.
Input:
-The first line contains one integer N.
-The second line contains N integers A1,A2,…,AN (0≤Ai<230).
Output:
Print sum, modulo 998244353.
Constraints
1≤N≤300000
Subtasks
10 points : 1≤N≤10
10 points : 1≤N≤500
10 points : 1≤N≤5000
70 points : 1≤N≤300000
Sample Input:
10
0 1 2 3 4 5 6 7 8 9
Sample Output:
160
LOGIC WILL BE UPLOADED SOON STAY TUNE AND 
PLEASE SHARE IT WITH YOUR FRIENDS TOO
 

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS

RELATED :

Related :

Related :

Leave a Comment