Editorial for DMOPC '21 Contest 3 P1 - Sums & Differences
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
We only get two queries. How can we determine both of the numbers? We have two queries, but let's just use . Let's query it twice. We will show a simulation of the array based on hidden variables and :
The first query returns . The second returns . We can use the output of the second query to determine , and the output of the first to determine from that.
Subtask 2
There exists a solution here that makes queries and solves a system of equations (after all, it's just equations with variables). However, we omit it, since it is long. We instead proceed to the last subtask, which contains an easier solution.
Full Solution
The full solution simply applies the subtask solution to the first two indices, and then after that queries for . Since we already know one variable and we get the output of the query, then , where is the current value in position , and is the output of the query (since the output is ). We then need to set to .
We end with some advice: if a problem is challenging, look at the subtasks. The first subtask should be a good hint. Even on problems without subtasks, making your own subtasks is very often helpful for approaching the final solution.
Comments