DOJ logoDOJ
Problems
Recently added problemsSaved problemsWorkbooks
CategoriesDLCContestsGroupsTeamsBoard
Ranking
Solved Problem RankingStreak rankingDOJ Power ranking
Status
Call for TasksLoginRegister
DOJ logoDOJ

Community online judge with OI-style subtask scoring, Elo ratings, and Discord account linking.

Problems
ProblemsCategories
Community
ContestsRankingBoardNoticesHost an external contestGuide
Account
LoginRegisterJudge Status
Policy
Terms of ServiceDLC RulesPrivacyAPI documentationLanguage runtimesContest rank rewardsRating and performance
© 2026 DOJ
All rights reserved
Editorial

OX Quiz

Back to problem

Editorial

Perfect scorers are exactly the students whose strings equal the key. For K>0K>0K>0, some string must have frequency KKK. For K=0K=0K=0, the number DDD of distinct strings must be less than 2M2^M2M. If M≥18M\geq18M≥18, then 2M>N2^M>N2M>N, so answer yes without evaluating the power. Sorting gives worst-case O(NMlog⁡N)O(NM\log N)O(NMlogN) time and O(NM)O(NM)O(NM) space. The shift is evaluated only for M<18M<18M<18, so it is at most 2172^{17}217. The small-subtask naive solution enumerates all 2M2^M2M keys in O(2MNM)O(2^MNM)O(2MNM) time.

Solution written by GPT6