题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12827&courseid=268

1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 using namespace std; 6 const int maxn = 100000+5; 7 char str[maxn]; 8 int main() 9 { 10 int T; 11 scanf("%d",&T); 12 while(T--) 13 { 14 scanf("%s",str); 15 int x1 = 0x7fffffff,y1 = 0x7fffffff,x2 = -0x7fffffff,y2 = -0x7fffffff; 16 int len = strlen(str),temp[5]; 17 memset(temp,0,sizeof(temp)); 18 for(int i = 0;i < len;++i) 19 if(str[i] == 'U') temp[0]++; 20 else if(str[i] == 'R') temp[1]++; 21 else if(str[i] == 'D') temp[2]++; 22 else if(str[i] == 'L') temp[3]++; 23 else temp[4]++; 24 printf("%d %d %d %d ",temp[1]-temp[3]-temp[4],temp[0]-temp[2]-temp[4],temp[1]-temp[3]+temp[4],temp[0]-temp[2] + temp[4]); 25 } 26 return 0; 27 } 28 29 30