include stdio include stdlib include string int main int 26 1000001 le

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main () {
int a[26]={0}, z=1000001, n, len, lenvsp, flag, op1, op2, i, j, k;
char op[3], op3[z], ll;
char *s=(char*)malloc(z*sizeof(char));
gets(s);
len=strlen(s);
int *mass=(int*)malloc(len*sizeof(int));
scanf("%d",&n);
for (i=0;i<n;i++) {
scanf("%s",&op[0]);
flag=0;
switch (op[0]) {
case 'H': {
scanf("%d%d", &op1, &op2);
for (k=0;k<len;k++) {
mass[k]=0;
if (k<26) a[k]=0;
}
for (k=op1;k<=op2;k++) a[s[k]-'a']++;
for (k=op1;k<=op2;k++) mass[k]=a[s[k]-'a'];
/*for (k=0;k<len;k++) printf("%c",s[k]);
printf("\n");
for (k=0;k<len;k++) printf("%d",mass[k]);
printf("\n");*/
if ((op2-op1+1)%2==0) {
for (j=op1;j<=op2;j++) {
if (mass[j]%2!=0) {
flag=1;
printf("NO\n");
break;
}
}
if (flag==0) printf("YES\n");
}
else {
for (j=op1;j<=op2;j++) {
if (mass[j]%2!=0) {
if (flag==0) {
flag++;
ll=s[j];
}
if (s[j]!=ll) flag++;
}
}
if (flag==1||flag==0) printf("YES\n");
else printf("NO\n");
//printf("%d\n",flag);
}
} break;
case 'U': {
scanf("%d ", &op1);
gets(op3);
lenvsp=strlen(op3);
for (k=op1,j=0;j<lenvsp;k++,j++) s[k]=op3[j];
}
//for (k=0;k<len;k++) printf("%c",s[k]);
//printf("\n");
}
}
free(s);
free(mass);
return 666;
}