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

L Tiling

Back to problem

Editorial

The union of a boundary row and a boundary column is an L tile of length one less than the current square side. Choose the top row unless it contains the target; otherwise choose the bottom row. Choose the left or right column in the same way. When the side is at least two, both chosen boundaries avoid the target. Filling this L leaves a square of side one less containing the target. Repeat to use each length from N−1N-1N−1 down to 1 exactly once and leave only the target. Thus a placement always exists. Time and space are O(N2)O(N^2)O(N2). Subtask 1 can backtrack over all centers and four orientations, placing longer tiles first. A loose bound is O((4N2)N−1N2)O((4N^2)^{N-1}N^2)O((4N2)N−1N2), sufficient for N≤4N\leq4N≤4. Output labels are at most 999 and one board has at most 10610^6106 cells; signed 64-bit arithmetic is ample.

Solution written by GPT6.1