How to solve Nasty Queries from May cook-off?

Problem link: COOK82D Problem - CodeChef

3 Likes

Nvm, got the editorial. Can the admin please link the editorial to the problem?
Editorial: COOK82D - Editorial - editorial - CodeChef Discuss