I - Near Pair 解説
by
simasima
Considering that the number of available queries is limited, it is impossible to identify all elements of the sequence. Therefore, it is necessary to identify only the endpoints.
Let us consider an undirected graph with \(N\) vertices, where edges are drawn between vertices \(i\) and \(j\) if \(|a_i−a_j|≤K\) \((i≠j)\). In this graph, the degree of most vertices is \(2K\) but the degree of vertices at the ends is less than \(2K\). Defining the edge deficiency of a vertex as \(2K−\)(degree of the vertex) , the sum of the edge deficiencies of all vertices is \(K(K+1)\), and the vertices \(x\) and \(y\) attain the maximum edge deficiency of \(K\).
Here, the return value of a query can be interpreted as the number of edges in the induced subgraph of a given vertex set. The difference between the number of edges in the induced subgraph of a vertex set \(S\) and the induced subgraph of the complement of \(S\) is twice the difference between the sum of the degrees of vertices in \(S\) and the sum of the degrees of vertices in the complement of \(S\). Therefore, by using 2 queries, the sum of the degrees of the vertices in a vertex set \(S\) can be determined, and the sum of the edge deficiencies of \(S\) can also be determined.
By updating the family of vertex sets \(\{A_i\}_{i=1}^m\) that might contain \(x\) or \(y\), this problem can be solved. Initially, the family \(\{A_i\}_{i=1}^m\) contains only the set of all vertices. For each set in \(\{A_i\}_{i=1}^m\), divide it into two subsets and remove those with an edge deficiency sum less than \(K\) from \(\{A_i\}_{i=1}^m\) . Since the total sum of edge deficiencies of all vertices is at least \(K(K+1)\), the number of elements in \(\{A_i\}_{i=1}^m\) is always at most \(K+1\). Therefore, \((K+1)\times 15 \times 2=30(K+1)\) queries or fewer are sufficient to identify \(x\) and \(y\).
投稿日時:
最終更新: