DOJ logoDOJ
LoginRegister
DOJ logoDOJ
Call for Tasks
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
Problems
Recently added problemsSaved problemsWorkbooks
CategoriesDLCContestsGroupsTeamsBoard
Ranking
Solved Problem RankingStreak rankingDOJ Power ranking
Status
Editorial

LED

Back to problem

Editorial

Treat the three components independently. In one update a component moves by at most one in each coordinate. After TTT updates an initial point can affect (X,Y)(X,Y)(X,Y) exactly when max⁡(∣xi−X∣,∣yi−Y∣)≤T\max(|x_i-X|,|y_i-Y|)\leq Tmax(∣xi​−X∣,∣yi​−Y∣)≤T. Necessity follows from the per-step coordinate bound. For sufficiency, move both coordinates toward the target simultaneously, then stay still for remaining steps. Bitwise OR the masks of all qualifying initial colors. This takes O(N)O(N)O(N) time and O(1)O(1)O(1) extra space. Subtask 1 permits direct propagation to nine neighbors for TTT rounds using a map, in O(TN(2T+1)2log⁡(N(2T+1)2))O(TN(2T+1)^2\log(N(2T+1)^2))O(TN(2T+1)2log(N(2T+1) time. Coordinate differences are at most 2⋅1062\cdot10^62⋅106 and masks at most 7; all arithmetic fits signed 64-bit integers.

Solution written by GPT6.1

2
))