Codeforce Round #226 Div2 B
→ Practice
You are registered for practice. You can solve problems unofficially. Results can be found in the contest status and in the bottom of standings.
1 #pragma comment(linker,"/STACK:102400000,102400000") 2 #include <cstdio> 3 #include <vector> 4 #include <cmath> 5 #include <queue> 6 #include <cstring> 7 #include <iostream> 8 #include <algorithm> 9 using namespace std; 10 #define INF 0x7fffffff 11 #define mod 1000000007 12 #define ll long long 13 #define maxn 5025 14 #define pi acos(-1.0) 15 int n, m; 16 char s[maxn]; 17 int a[maxn][maxn]; 18 int main(){ 19 scanf("%s", s); 20 n = strlen(s); 21 int x = -1; 22 for (int i = 0; i < n; i++){ 23 if (s[i] == 'b'&&s[i + 1] == 'e'&&s[i + 2] == 'a'&&s[i + 3] == 'r'){ 24 for (int k = x + 1; k <= i; k++){ 25 for (int j = i + 3; j < n; j++){ 26 a[k][j] = 1; 27 } 28 } 29 x = i; 30 } 31 } 32 int t = 0; 33 for (int i = 0; i < n;i++) 34 for (int j = i+3; j < n; j++){ 35 if (a[i][j])t++; 36 } 37 printf("%d\n", t); 38 return 0; 39 }




浙公网安备 33010602011771号