题目链接:​​传送门​

每个字母附一个不同的值,范围要大
维护区间和
样例太水了没有修改
不开O2会T最后一个点
懒得再改输入了

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <algorithm>
#include <climits>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define
#define

using namespace std;
typedef long long ll;
struct node {
int l, r; ll w, f;
}tree[A];
ll s[A];
int n, m, a, b;
void build(int k, int l, int r) {
tree[k].l = l; tree[k].r = r;
if (l == r) {
tree[k].w = s[l];
return;
}
int m = (l + r) >> 1;
build(k << 1, l, m);
build(k << 1 | 1, m + 1, r);
tree[k].w = tree[k << 1].w + tree[k << 1 | 1].w;
}
void down(int k) {
tree[k << 1].f = tree[k << 1 | 1].f = tree[k].f;
tree[k << 1].w = (tree[k << 1].r - tree[k << 1].l + 1) * tree[k].f;
tree[k << 1 | 1].w = (tree[k << 1 | 1].r - tree[k << 1 | 1].l + 1) * tree[k].f;
tree[k].f = 0;
}
void change(int k, int l, int r, ll val) {
if (tree[k].l >= l and tree[k].r <= r) {
tree[k].w = (ll)(tree[k].r - tree[k].l + 1) * val;
tree[k].f = val;
return;
}
if (tree[k].f) down(k);
int m = (tree[k].l + tree[k].r) >> 1;
if (l <= m) change(k << 1, l, r, val);
if (r > m) change(k << 1 | 1, l, r, val);
tree[k].w = tree[k << 1].w + tree[k << 1 | 1].w;
}
ll ask(int k, int l, int r) {
if (tree[k].l >= l and tree[k].r <= r) return tree[k].w;
if (tree[k].f) down(k);
int m = (tree[k].l + tree[k].r) >> 1; ll ans = 0;
if (l <= m) ans += ask(k << 1, l, r);
if (r > m) ans += ask(k << 1 | 1, l, r);
return ans;
}
ll askpoint(int k, int l) {
if (tree[k].l == tree[k].r) return tree[k].w;
if (tree[k].f) down(k);
int m = (tree[k].l + tree[k].r) >> 1;
if (l <= m) return askpoint(k << 1, l);
else return askpoint(k << 1 | 1, l);
}
ll trans(char opt) {
if (opt == 'A') return ll(opt * 1234);
else if (opt == 'B') return ll(opt * 12345);
else return ll(opt * 123456);
}
bool check(ll x, char opt, int a, int b) {
if (opt == 'A') return x == ll(opt * 1234) * (b - a + 1);
else if (opt == 'B') return x == ll(opt * 12345) * (b - a + 1);
else return x == ll(opt * 123456) * (b - a + 1);
}

int main(int argc, char const *argv[]) {
cin >> n;
for (int i = 1; i <= n; i++) {
char opt; cin >> opt;
s[i] = trans(opt);
}
build(1, 1, n);
cin >> m;
while (m--) {
char opt, tns; cin >> opt;
if (opt == 'A') {
scanf("%d%d", &a, &b); cin >> tns;
change(1, a, b, trans(tns));
}
else {
scanf("%d%d", &a, &b); ll x = ask(1, a, b);
if ((a == 1 or b == n or askpoint(1, a - 1) != askpoint(1, b + 1)) and (check(x, 'A', a, b) or check(x, 'B', a, b) or check(x, 'C', a, b))) puts("Yes");
else puts("No");
}
}
return 0;
}