题目链接:http://codeforces.com/gym/100712/attachments
水题,模拟一下就好了。
附上AC代码:
#include <bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000, 102400000")
using namespace std;
const int maxn = 105;
char str[maxn];
bool vis[maxn];
int n;
int main(){
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int T;
scanf("%d", &T);
while (T--){
scanf("%d", &n);
scanf("%s", str);
int ans=0, len=strlen(str);
memset(vis, false, sizeof(bool)*n);
for (int i=0; i<len; ++i){
if (str[i] == '*'){
vis[i] = true;
if (i-1>=0 && str[i-1]=='.')
vis[i-1] = true;
if (i+1<len && str[i+1]=='.')
vis[i+1] = true;
}
}
for (int i=0; i<len; ++i)
if (!vis[i]){
++ans;
vis[i] = true;
if (i+1<len && !vis[i+1])
vis[i+1] = true;
if (i+2<len && !vis[i+2])
vis[i+2] = true;
}
printf("%d\n", ans);
}
return 0;
}