Created
August 13, 2017 10:04
-
-
Save hrsvrdhn/01e9b9d50dba2892c01a287ff10e1b1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
#define all(a) a.begin(),a.end() | |
#define ll long long | |
#define inp(a) scanf("%d",&a) | |
#define out(a) printf("%d\n",a) | |
#define inp2(a) scanf("%lld",&a) | |
#define out2(a) printf("%lld\n",a) | |
#define arrinput(a,n) for(int i=0;i<n;i++) scanf("%d",&a[i]); | |
#define pii pair<int,int> | |
#define piii pair<int,pair<int,int> > | |
#define vi vector<int> | |
#define rep(i,start,n) for(int i=start;i<n;i++) | |
#define pb push_back | |
#define F first | |
#define S second | |
#define mp make_pair | |
#define vb vector<bool> | |
#define testcases() int test;scanf("%d",&test);while(test--) | |
#define priorityqueue priority_queue<int,vector<int>,greater<int> > | |
#define minheappop(a) pop_heap(a.begin(),a.end(),compare);a.pop_back(); | |
#define maxheappop(a) pop_heap(a.begin(),a.end());a.pop_back(); | |
#define minheappush(a,b) a.push_back(b);push_heap(a.begin(),a.end(),compare); | |
#define maxheappush(a,b) a.push_back(b);push_heap(a.begin(),a.end()); | |
const int mod=1000000007; | |
using namespace std; | |
int main() | |
{ | |
int n,q,type,index,l,r; | |
string s; | |
char ch; | |
inp(n);inp(q); | |
cin>>s; | |
vector< vector<int> > bit(n+1,vector<int>(26,0)); | |
rep(i,0,n) | |
{ | |
index=i+1; | |
while(index<=n) | |
{ | |
bit[index][s[i]-'a']++; | |
index+=(index&-index); | |
} | |
} | |
while(q--) | |
{ | |
inp(type); | |
if(type==1) | |
{ | |
cin>>l>>ch; | |
if(ch!=s[l-1]) | |
{ | |
index=l; | |
while(index<=n) | |
{ | |
bit[index][s[l-1]-'a']--; | |
bit[index][ch-'a']++; | |
index+=(index&-index); | |
} | |
s[l-1]=ch; | |
} | |
} | |
else if(type==2) | |
{ | |
inp(l);inp(r); | |
vector<int> counts(26,0); | |
index=r; | |
while(index>0) | |
{ | |
for(int i=0;i<26;i++) | |
counts[i]+=bit[index][i]; | |
index-=(index&-index); | |
} | |
index=l-1; | |
while(index>0) | |
{ | |
for(int i=0;i<26;i++) | |
counts[i]-=bit[index][i]; | |
index-=(index&-index); | |
} | |
int flag; | |
if((r-l+1)%2) | |
flag=2; | |
else | |
flag=1; | |
int i; | |
for(i=0;i<26;i++) | |
{ | |
if(counts[i]%2) | |
flag--; | |
if(!flag) | |
break; | |
} | |
if(i!=26) | |
printf("no\n"); | |
else | |
printf("yes\n"); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment