Posted on 2008-04-14 21:17
superman 阅读(233)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1171 C++ 00:00.40 488K */
2 #include <stdio.h>
3
4 int main()
5 {
6 int n, N;
7 char p[100000];
8
9 scanf("%d", &N);
10 while(N--)
11 {
12 scanf("%d", &n);
13 for(int i = 0; i < n; )
14 {
15 scanf("%c", p + i);
16 if(p[i] == 'U' || p[i] == 'D')
17 i++;
18 }
19
20 int ans = 0, pos = 0;
21 for(int i = 1; i < n; i++)
22 if(p[i] != p[pos])
23 {
24 pos = i;
25 ans++;
26 }
27
28 printf("%d\n", ans);
29 if(N)
30 putchar('\n');
31 }
32
33 return 0;
34 }
35