The bear has a string s ?=? s 1 s 2 ... s | s | (record | s | is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices i ,? j (1?≤? i ?≤? j ?≤?| s |) , that string x (
The bear has a string s ?=? s 1 s 2 ... s | s | (record | s | is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices i ,? j (1?≤? i ?≤? j ?≤?| s |) , that string x ( i ,? j )?=? s i s i ?+?1 ... s j contains at least one string " bear " as a substring.
String x ( i ,? j ) contains string " bear ", if there is such index k ( i ?≤? k ?≤? j ?-?3) , that s k ?=? b , s k ?+?1 ?=? e , s k ?+?2 ?=? a , s k ?+?3 ?=? r .
Help the bear cope with the given problem.
查看更多关于CodeforcesRound#226(Div.2)的详细内容...