【P4979 矿洞:坍塌】题解
Solution
先说句闲话,本来看到这个题目想写线段树的,但是发现暴力有 70,就先写了暴力,结果暴力直接过了,数据好水,那就宣传一下这道题能写暴力吧 /cy。
下面的
替换的时候直接从
查询的话也是从
最后的时候判断一下
开始的时候把
要吸氧才能过。
Code
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int Maxk = 5e5 + 10;
int n,m;
char s[Maxk];
int a[Maxk];
struct Node{
int l_;
int r_;
int tag_;
}t[Maxk << 2];
inline int read()
{
int s = 0, f = 0;char ch = getchar();
while (!isdigit(ch)) f |= ch == '-', ch = getchar();
while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
return f ? -s : s;
}
signed main()
{
n = read();
cin >> s + 1;
for(int i = 1;i <= n;i ++) a[i] = s[i] - 'A' + 1;
a[n + 1] = 7;
m = read();
for(int i = 1;i <= m;i ++) {
char z;cin >> z;
if(z == 'A') {
int x = read(),y = read();
char op;cin >> op;
for(int j = x;j <= y;j ++) a[j] = op - 'A' + 1;
}
else {
int x = read(),y = read();
bool f = false;
for(int j = x + 1;j <= y;j ++) if(a[j - 1] != a[j]) {f = true;break;}
if(a[x - 1] == a[y + 1]) f = true;
if(f) puts("No");
else puts("Yes");
}
}
return 0;
}