代码如下:
#include<bits/stdc++.h>
#define int long long
#define maxn 500010
using namespace std;
int n,q;
string s;
map<int,char> m;
bitset<maxn> bs;//第i位是大写(true)还是小写(false)?
inline void init(){
bs.reset();
for(int i=0;i<=n;i++){
m[i]='-';
}
for(int i=0;i<n;i++){
if(s[i]<=90) bs[i]=true;
}
}
signed main(){
cin>>n>>s>>q;
init();
for(int i=1;i<=q;i++){
char c;
int x,y;
cin>>x>>y>>c;
if(x==1){
m[y]=c;
if(c<=90) bs[y]=true;
else bs[y]=false;
}
else if(x==2){
bs.reset();
}
else if(x==3){
bs.set();
}
//cout<<bs[5]<<endl;
}
for(int i=0;i<n;i++){
char c=s[i];
if(m[i+1]!='-') c=m[i+1];
if(c<=90&&!bs[i+1]) c+=32;
else if(c>=90&&bs[i+1]) c-=32;
cout<<c;
}
return 0;
}
不建议去题解区翻找 我已经翻了半个小时了 思路千篇一律……