标签:
1 #include<stdio.h> 2 #include<math.h> 3 #include<string.h> 4 #include<stdlib.h> 5 #include<ctype.h> 6 #define max(a, b)(a < b ? a : b) 7 #define N 80010 8 9 char s[N]; 10 11 void slove(char s[], int a, int b) 12 { 13 int i; 14 for(i = a ; i <= b ; i++) 15 { 16 if(s[i] == ‘z‘) 17 s[i] = ‘a‘; 18 else 19 s[i] += 1; 20 } 21 } 22 int main() 23 { 24 int t, len, n; 25 char ch, ch1; 26 int a, b, c, i, j, h; 27 scanf("%d", &t); 28 while(t--) 29 { 30 scanf("%d%d ", &len, &n); 31 scanf("%s", s); 32 for(i = 0 ; i < n ; i++) 33 { 34 scanf(" %c", &ch); 35 if(ch == ‘Q‘) 36 { 37 scanf("%d", &c); 38 printf("%c\n", s[c - 1]); 39 } 40 else 41 { 42 scanf("%d%d", &a, &b); 43 if(ch == ‘R‘) 44 { 45 for(h = a - 1, j = b - 1 ; h <= j ; h++, j--) 46 { 47 ch1 = s[h]; 48 s[h] = s[j]; 49 s[j] = ch1; 50 } 51 } 52 else if(ch == ‘S‘) 53 slove(s, a - 1, b - 1); 54 } 55 } 56 } 57 return 0; 58 }
HDU 1981 A Special Text Editor
标签:
原文地址:http://www.cnblogs.com/yishilin/p/4448341.html