Ant Query

Scientists from the planet Krypton have figured out a way to grow artificial sugar in space. They ha…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

Shouldn’t the answer of case #2 query no 4 be 8? It’'s the maximum distance the ant has to travel whuch is from the 3rd sugar stock, isn’t it?

@hjr265 ভাই। মনে হয় টিসিতে ভুল আছে। প্রশ্নে মিনিমাম বলা থাকলেও সবাই ম্যাক্সিমাম দিয়ে সলভ করেছে। এটি নিশ্চয়ই টাফবাসিদের বিভ্রান্ত করার একটি চক্রান্ত। বিষয়টি খতিয়ে দেখার অনুরোধ করা হলো।

1 Like

@touhidur Let me get in touch with the round’s coordinator and get some insights.

1 Like

Please read the problem statement carefully.

“The cosmic ant always chooses the shortest possible path along the grid lines while going from stock X to stock Y. The ant has an Energy capacity, and he loses 1 unit energy in walking 1 unit of distance.”

Here shortest path on grid line means manhattan distance.

“Then they will ask you to find out the minimum required energy capacity for the ant such that the ant can visit any sugar stock from any other sugar stock.”

And here minimum required energy capacity for visiting any point to any other point on grid means that minimum manhattan distance between farthest two points available on the grid. So you have to calculate the maximum of minimum distance between all possible pair of points on the grid.

Lastly all test cases are correct and You can have a look on the editorial for the solution idea.

2 Likes

সরি, আমি ভেবেছিলাম শর্টেস্ট পাথে রিকোয়ারড এনার্জি জানতে চাওয়া হয়েছে। এনার্জি স্টক এমন হবে যাতে যেকোনো নোড থেকে যেকোনো নোডে যেতে পারে বিষয়টি খেয়াল করিনি। প্রবলেম স্ট্যটমেন্টটি বুঝিয়ে দেয়ার জন্য ধন্যবাদ। এর মাধ্যমে টাফবাসিরা বিভ্রান্তি থেকে মুক্তি পাবে ইনশাআল্লাহ।

If anyone need detail explanation with code here

Sorry i misunderstood the question. I thought it was asking for maximum manhattan distance from a single point to other points not from any point to any other point. Please forgive my silliness.