help with a question in a recent contest at CODECHEF JUNE Lunchtime 2020
Difference between en1 and en2, changed 162 character(s)
problem: https://www.codechef.com/LTIME85A/problems/COWSHEDS↵

I was able to solve it when the constraints are less, how to solve it efficiently? 

Editorial for this question hasn't been released yet. So, it would be of great help if you could explain your approach and key concepts along with the solution.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English rishi7 2020-06-29 19:44:23 162
en1 English rishi7 2020-06-29 19:42:28 219 Initial revision (published)