Editorial for Xây dựng cây
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1: Ta liệt kê các đồ thị dạng cây có thể với đỉnh và kiểm tra với từng test case.
Độ phức tạp:
Subtask 2: Gọi là giá trị
lớn nhất và
là số lượng chỉ số
thỏa mãn
. Khi đó, điều kiện cần và đủ của mảng
để có thể xây dựng cây là:
với mọi
.
với mọi
.
nếu
chẵn và
nếu
lẻ.
Độ phức tạp:
Comments