DOJ logoDOJ
Problems
Recently added problemsSaved problems
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-backed certification.

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

Find the Plane

Back to problem

Editorial

Let XXX be the point outside the plane. Consider a set AAA of at least four point indices.

If X∉AX \notin AX∈/A, every selected point lies on Π\PiΠ, so the answer is YES.

If X∈AX \in AX∈A, the set also contains at least three points on Π\PiΠ. These three points are not collinear, so the unique plane containing them is Π\PiΠ. Since XXX does not lie on Π\PiΠ, the answer is NO.

Therefore, a query containing at least four points tells us exactly whether the queried set contains XXX.

Initially, let the candidate set be C={1,2,⋯ ,N}C=\{1,2,\cdots,N\}C={1,2,⋯,N}. We maintain the invariant X∈CX \in CX∈C.

While ∣C∣>9|C|>9∣C∣>9, split CCC into two sets AAA and BBB whose sizes differ by at most one. Query AAA. If the answer is NO, replace with . Otherwise, replace with . Both parts have size at least five, so the criterion above is always valid.

After this process, 5≤∣C∣≤95 \leq |C| \leq 95≤∣C∣≤9. For every x∈Cx \in Cx∈C, query C∖{x}C \setminus \{x\}C∖{x}. This set has at least four points. The answer is exactly when , so this identifies the answer.

The sum of the queried set sizes during the halving phase is less than NNN. The final phase uses at most nine queries of at most eight points each. Thus, the sum of kkk over all queries is less than N+72N+72N+72, which is at most 100 072100\,072100072.

Suppose the halving phase uses ttt queries and leaves mmm candidates. If t≤13t \leq 13t≤13, then m≤9m \leq 9m≤9, so the total number of queries is t+m≤22t+m \leq 22t. If , then implies , so at most queries are used. Therefore, the algorithm always uses at most queries.

The time complexity, including all printed indices, is O(N)O(N)O(N), and the memory complexity is O(N)O(N)O(N).

CC
C
AAA
CCC
BBB
YES
x=Xx=Xx=X
+
m≤
22
t=14t=14t=14
N≤100 000N \leq 100\,000N≤100000
m≤⌈100 000/214⌉=7m \leq \lceil 100\,000/2^{14}\rceil=7m≤⌈100000/214⌉=7
212121
222222