Скоро Codeforces Round 1133 (Div. 1, Div. 2)! Регистрация здесь. ×
Adjacent XORs problem from a past CodeChef contest.
Разница между en1 и en2, 1 символ(ов) изменены
The problem goes like : ↵
↵
We are given an array $A$ of size $N$ consisting of positive integers and an integer $X$. We can perform the following operation **atmost once**.↵
↵
- choose any subsequence of $A$, add $X$ to each element in that subsequence.↵
↵
The final motive is to maximise the sum $\sum_{i=2}^{N}(A_{i-1} \oplus A_i)$.↵
↵
I don't remember the exact constraints on the values of $A_i, \ N \ or X$, but I dont' think they matter much. $N$ is sufficiently large so that the bruteforce exhaustive search won't work. The offical solution uses Dynamic Programming. ↵
↵
I am looking for rigorously justifying that approach. I am unable to prove the two necessary properties for a DP solution namely: ↵
↵
-  optimal substructure↵
-  overlapping subproblems↵
↵
I would highly appreciate someone writing the proof or atleast giving me an outline of the proof.↵
↵
Attached below is the algorithm writte
n in C++.↵
[Link to the image](/predownloaded/17/3d/173d93e3ff19495104d5b1280b4af767478527c1.png)

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский limbu_timbu 2026-01-18 11:27:13 1 Tiny change: 'thm writte in C++.\n' -> 'thm written in C++.\n'
en1 Английский limbu_timbu 2026-01-18 11:25:58 1055 Initial revision (published)