428 传统题

[CF1974C] 美丽三元组对 (Beautiful Triple Pairs)

时间限制
4000ms
内存限制
256MiB
登顶 / 尝试
1/ 1
难度
4
    上传者 标签CodeforcesCF1974提高-容斥哈希/排序

[CF1974C] 美丽三元组对 (Beautiful Triple Pairs)

Given array a of length n. Consider triples [a_j, a_{j+1}, a_{j+2}] for 1 <= j <= n-2. Count pairs of triples differing in exactly one of the three positions. Constraints: 1 <= t <= 10^4, 3 <= n <= 210^5, 1 <= a_i <= 10^6, sum(n) <= 210^5.