I can understand your problem, it's a different type of problem, but I will try to explain you. We are not interested in v[i], but we are interested in vi%x and vi%y. So first perform this operation on each element, so each element will break in a pair {a ,b}i. If pair{ai,bi} can make a good pair with {aj, bj} then (ai+aj)%x=0 and (bi-bj)%y=0. So use this property. If we have a pair{aj,bj} we can compute corresponding pari(ai,bi) . If it is already in map then we we can get it in logn time. I hope it will help you.
@@AnkitRaj-zm3me fir each vi we convert it in pair of {a,b} and then we will calculat desired {aj,bj}. If it is in 0....i-1 index, then we will get from map because after each iteration we are storing vi--> {ai, bi} in map.
I can understand your problem, it's a different type of problem, but I will try to explain you. We are not interested in v[i], but we are interested in vi%x and vi%y. So first perform this operation on each element, so each element will break in a pair {a ,b}i. If pair{ai,bi} can make a good pair with {aj, bj} then (ai+aj)%x=0 and (bi-bj)%y=0. So use this property. If we have a pair{aj,bj} we can compute corresponding pari(ai,bi) . If it is already in map then we we can get it in logn time. I hope it will help you.
good explanation but why did you use plus x in eq ((x-a)+x )%x. only point i didn't understand and u didn't explain this on paper but you used it in your code
good explanation
Thanks
I can understand your problem, it's a different type of problem, but I will try to explain you.
We are not interested in v[i], but we are interested in vi%x and vi%y. So first perform this operation on each element, so each element will break in a pair {a ,b}i.
If pair{ai,bi} can make a good pair with {aj, bj} then (ai+aj)%x=0 and (bi-bj)%y=0.
So use this property. If we have a pair{aj,bj} we can compute corresponding pari(ai,bi) . If it is already in map then we we can get it in logn time.
I hope it will help you.
thanks for help.but how will we search because for each iteration there will be different element.
@@AnkitRaj-zm3me fir each vi we convert it in pair of {a,b} and then we will calculat desired {aj,bj}. If it is in 0....i-1 index, then we will get from map because after each iteration we are storing vi--> {ai, bi} in map.
@@shivammishra6220 finally understood the solution in evening . i do not understand why it too long to understand it.
found it difficult to understand and grasp the logic , what should i do for this problem? tried different editorials but could not get it fully.
I can understand your problem, it's a different type of problem, but I will try to explain you.
We are not interested in v[i], but we are interested in vi%x and vi%y. So first perform this operation on each element, so each element will break in a pair {a ,b}i.
If pair{ai,bi} can make a good pair with {aj, bj} then (ai+aj)%x=0 and (bi-bj)%y=0.
So use this property. If we have a pair{aj,bj} we can compute corresponding pari(ai,bi) . If it is already in map then we we can get it in logn time.
I hope it will help you.
good explanation but why did you use plus x in eq ((x-a)+x )%x. only point i didn't understand and u didn't explain this on paper but you used it in your code
In some cases (X-a) may be negative , so just for the safety purpose we have added extra X and then taken it's mod.
was this round rated?