AtCoder Beginner Contest 162
翻译中…
Problem Statement
翻译中…
We have a string $S$ of length $N$ consisting of R, G, and B.
翻译中…
Find the number of triples $(i,~j,~k)~(1 \leq i < j < k \leq N)$ that satisfy both of the following conditions:
翻译中…
$S_i \neq S_j$,$S_i \neq S_k$, and$S_j \neq S_k$.$j - i \neq k - j$.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 4000$$S$is a string of length$N$consisting ofR,G, andB.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
S
翻译中…
Output
翻译中…
Print the number of triplets in question.
翻译中…
样例
Input #1
4
RRGB
Output #1
1
Only the triplet $(1,~3,~4)$ satisfies both conditions. The triplet $(2,~3,~4)$ satisfies the first condition but not the second, so it does not count.
Input #2
39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB
Output #2
1800
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。