题意: 给定数字序列 2种操作
1. 将[l,r]区间数字变成c
2. 查询[l,r]区间数字串是不是周期为d的串
x is called a period of string s (1 ≤ x ≤ |s|), if si = si + x for all i from 1 to |s| - x.
分析: 线段树+哈希 用线段树维护[l,r]区间的数字串的哈希值 查询的时候只要判断长度为r-l+1-d的前缀和后缀是否相同
防止哈希碰撞 这里用双关键字双哈希
代码:
//
// Created by TaoSama on 2015-09-23
// Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include
#include
#include
#include
#include
#include
#include
#include
#include
蓝儿暴力也能过这个题
int main(){
int n, m, k, op, l, r, x;
scanf("%d%d%d", &n, &m, &k);
scanf("%s", s + 1);
for(int i = 0; i < m + k; i++) {
scanf("%d%d%d%d", &op, &l, &r, &x);
if(op == 1) memset(s + l, x + '0', r - l + 1);
else puts(memcmp(s + l, s + l + x, r - l + 1 - x) ? "NO" : "YES");
}
}