Did E with prefix sum. Calculated initial 0_xor and 1_xor. Then say if some segment is flipped, for 0_xor(same for 1_xor) we have to remove XORs of elements which were initially 0 and add XORs of elements which become zero after the flip. Taking the xor of this segment (arr[l]xor arr[l+1].....xor arr[r]) with 0_xor will directly achieve this, >Elements corresponding to 0 before flip will get removed as A xor A=0 >And if they didn't get removed means they corresponded to 1 before the flip. Also if you don't mind, I think a brief section discussing your line of thought for the problem you couldn't solve would be nice.
Yes that makes sense. And again you don't need to have to calculate both values separately. You can just calculate one of them. And I don't discuss the unsolved problems because my idea might be completely wrong. So I don't want to give wrong ideas to the people watching these videos.
You will realize that the odd case is just a generalization of the even case. 2 is also a prime divisor of any even number. If I want gcd to be greater than 1 then there must be something common between the two numbers and if b is a multiple of a then a can definitely be the gcd.
I did it in this way: U need to search if there is any composite number from l to r If u find one print its first factor and the other one is (composite number - first factor) And in case u don't find one output -1
Amazing explanation!
Keep uploading videos.
Did E with prefix sum.
Calculated initial 0_xor and 1_xor.
Then say if some segment is flipped, for 0_xor(same for 1_xor) we have to remove XORs of elements which were initially 0 and add XORs of elements which become zero after the flip.
Taking the xor of this segment
(arr[l]xor arr[l+1].....xor arr[r])
with 0_xor will directly achieve this,
>Elements corresponding to 0 before flip will get removed as A xor A=0
>And if they didn't get removed means they corresponded to 1 before the flip.
Also if you don't mind, I think a brief section discussing your line of thought for the problem you couldn't solve would be nice.
Yes that makes sense. And again you don't need to have to calculate both values separately. You can just calculate one of them.
And I don't discuss the unsolved problems because my idea might be completely wrong. So I don't want to give wrong ideas to the people watching these videos.
what extesion you are using for showing and hiding the tags of the problem on codeforces ??
Hi
I have made that extension and that is called Codeforces GetRating. You can find it on Chrome as well as Firefox web store.
In the problem B, why did you take the most minimum distance of all the distances?
❤
what are the resources you recommend for learing segment trees
For problem C, how do you arrive that I have to find prime divisor for odd case
You will realize that the odd case is just a generalization of the even case. 2 is also a prime divisor of any even number.
If I want gcd to be greater than 1 then there must be something common between the two numbers and if b is a multiple of a then a can definitely be the gcd.
@@cpwithcpp got it
I did the question in a different way , I made 3 cases when the difference between numbers is 0 , 1 and >=2
prime number are aways odd
In the problem C, what to do when l == r and r is odd and I cant find any prime factors? I cant solve the last sample input , 9840769 9840769,
I did it in this way:
U need to search if there is any composite number from l to r
If u find one print its first factor and the other one is (composite number - first factor)
And in case u don't find one output -1
9840769 has 3137 as a prime divisor.
So you answer can be 3137 and (9840769 - 3137)
thank you so much guys