小红有一个长度为 n 的字符串 s=s1,s2,…,sn,她定义长度为 3 的子序列 sisjsk 的权值为 ∣i−j∣+∣i−k∣+∣j−k∣ 。
现在,小红希望你计算所有 “red” 子序列的权值之和。
如果字符串 t=“red” 可以通过删除字符串 s 中的若干(可能为零或全部)元素得到,则字符串 t 是字符串 s 的 “red” 子序列。
第一行输入一个整数 n(1≤n≤2×105) ,表示字符串的长度。
Scan the QR code below with WeChat to sign in
First-time scan will create your account automatically
请使用微信扫描下方二维码完成注册