T组数据,每组有n行,每行为下面三种格式之一:
C x
B x
S
其中x为一个正整数,x值从1连续增长到k的一组C序列或者B序列视为一个pattern,单独的一个S视为一个pattern。
统计序列中pattern的总数。即C或B后面是1就ans++,遇到S就ans++。
#include<bits/stdc++.h>
#define CPY(A,B)memcpy(A,B,sizeof(A))
typedef long long LL;
typedef unsigned long long uLL;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const LL INFF=0x3f3f3f3f3f3f3f3fLL;
const double EPS=1e-8;
const double OO=1e20;
const double PI=acos (-1.0);
int dx[]= {0,1,0,-1};
int dy[]= {1,0,-1,0};
int gcd (const LL &a,const LL &b) {return b==0?a:gcd (b,a%b);}
using namespace std;
char s[5];
int main() {
int n;
while (~scanf ("%d",&n) ) {
int ans=0;
for (int i=0; i<n; ++i) {
scanf ("%s",s);
int x;
if (s[0]=='S') {
++ans;
continue;
}
scanf ("%d",&x);
if (x==1) {++ans;}
}
printf ("%d\n",ans);
}
return 0;
}