看题解有大佬有线段树,这题不是直接模拟就完了吗,L1 5分水题
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 10;
int main(){
int n;
cin>>n;
string s1, s2;
cin>>s1;
cin>>s2;
int ans = 0;
for(int i = 0; i < n; i++){
if(s1[i] == s2[i] && s1[i] == '1') ans ++;
}
int m;
cin>>m;
char c;
int a, b;
while(m--){
cin>>c;
if(c == 'A'){
cin>>a>>b;
for(int i = a - 1; i < b; i ++){
if(s1[i] != s2[i] && s1[i] == '0'){
ans ++;
}
}
s1.replace(a - 1, b - a + 1, b -a + 1,'1');
}
else {
cin>>a>>b;
for(int i = a - 1; i < b; i ++){
if(s1[i] != s2[i] && s2[i] == '0'){
ans ++;
}
}
s2.replace(a - 1, b - a + 1,b -a + 1 ,'1' );
}
cout<<ans;
if(m != 0) cout<<endl;
}
return 0;
}