亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

Codeforces Round #321 (Div. 2)E 線段樹+字符串hash

2019-11-10 18:39:15
字體:
來源:轉載
供稿:網友

E. Kefa and Watch time limit per test1.5 seconds memory limit per test256 megabytes inputstandard input outputstandard output One day Kefa the parrot was walking down the street as he was on the way home from the restaurant when he saw something glittering by the road. As he came nearer he understood that it was a watch. He decided to take it to the pawnbroker to earn some money.

The pawnbroker said that each watch contains a serial number rePResented by a string of digits from 0 to 9, and the more quality checks this number passes, the higher is the value of the watch. The check is defined by three positive integers l, r and d. The watches pass a check if a substring of the serial number from l to r has period d. Sometimes the pawnbroker gets distracted and Kefa changes in some substring of the serial number all digits to c in order to increase profit from the watch.

The seller has a lot of things to do to begin with and with Kefa messing about, he gave you a task: to write a program that determines the value of the watch.

Let us remind you that number x is called a period of string s (1?≤?x?≤?|s|), if si??=??si?+?x for all i from 1 to |s|??-??x.

Input The first line of the input contains three positive integers n, m and k (1?≤?n?≤?105, 1?≤?m?+?k?≤?105) — the length of the serial number, the number of change made by Kefa and the number of quality checks.

The second line contains a serial number consisting of n digits.

Then m?+?k lines follow, containing either checks or changes.

The changes are given as 1 l r c (1?≤?l?≤?r?≤?n, 0?≤?c?≤?9). That means that Kefa changed all the digits from the l-th to the r-th to be c.

The checks are given as 2 l r d (1?≤?l?≤?r?≤?n, 1?≤?d?≤?r?-?l?+?1).

Output For each check on a single line print “YES” if the watch passed it, otherwise print “NO”.

Examples input 3 1 2 112 2 2 3 1 1 1 3 8 2 1 2 1 output NO YES input 6 2 3 334934 2 2 5 2 1 4 4 3 2 1 6 3 1 2 3 8 2 3 6 1 output NO YES NO Note In the first sample test two checks will be made. In the first one substring “12” is checked on whether or not it has period 1, so the answer is “NO”. In the second one substring “88”, is checked on whether or not it has period 1, and it has this period, so the answer is “YES”.

In the second statement test three checks will be made. The first check processes substring “3493”, which doesn’t have period 2. Before the second check the string looks as “334334”, so the answer to it is “YES”. And finally, the third check processes substring “8334”, which does not have period 1.

這個題有幾個坑點 第一個就是需要雙關鍵字hash 第二個是在線段樹更新的過程中需要去掉不需要的長度 第三個是lazy在用到的時候必須進行更新 其實也不算坑點 還是自己菜吧…

#include<iostream>#include<cstring>#include<string>#include<map>using namespace std;int mo1 = 1000000009, mo2 = 1000000007;unsigned long long p1[100011], s1[110001], p2[110001], s2[101001];int bas = 17;struct QQ{ long long z, y, chang, z1, z2, lazy;};qq shu[600001];string q;void jian(int gen, int zuo, int you){ shu[gen].z = zuo; shu[gen].y = you; shu[gen].lazy = -1; if (zuo == you) { shu[gen].z1 = (q[zuo-1] - '0') % mo1; shu[gen].z2 = (q[zuo-1] - '0') % mo2; return; } int mid = (zuo + you) / 2; jian(2 * gen, zuo, mid); jian(2 * gen + 1, mid + 1, you); shu[gen].z1 = (p1[shu[2 * gen + 1].y - shu[2 * gen + 1].z +1] * shu[2 * gen].z1 + shu[2 * gen + 1].z1) % mo1; shu[gen].z2 = (p2[shu[2 * gen + 1].y - shu[2 * gen + 1].z +1] * shu[2 * gen].z2 + shu[2 * gen + 1].z2) % mo2;}void gengxin(int gen, int zuo, int you, int wz, int wy, int bian){ if (zuo >= wz&&you <= wy) { shu[gen].lazy = bian; shu[gen].z1 = bian*s1[you - zuo] % mo1; shu[gen].z2 = bian*s2[you - zuo] % mo2; return; } else if (zuo > wy || you < wz)return; else { int mid = (zuo + you) / 2; if (shu[gen].lazy != -1) { shu[2 * gen].lazy = shu[2 * gen + 1].lazy = shu[gen].lazy; shu[gen].lazy = -1; shu[2 * gen].z1 = (shu[2 * gen].lazy*s1[shu[2 * gen].y - shu[2 * gen].z]) % mo1; shu[2 * gen].z2 = (shu[2 * gen].lazy*s2[shu[2 * gen].y - shu[2 * gen].z]) % mo2; shu[2 * gen + 1].z1 = (shu[2 * gen].lazy*s1[shu[2 * gen + 1].y - shu[2 * gen + 1].z]) % mo1; shu[2 * gen + 1].z2 = (shu[2 * gen].lazy*s2[shu[2 * gen + 1].y - shu[2 * gen + 1].z]) % mo2; } gengxin(2 * gen, zuo, mid, wz, wy, bian); gengxin(2 * gen + 1, mid + 1, you, wz, wy, bian); shu[gen].z1 = (p1[shu[2 * gen + 1].y - shu[2 * gen + 1].z + 1] * shu[2 * gen].z1 + shu[2 * gen + 1].z1) % mo1; shu[gen].z2 = (p2[shu[2 * gen + 1].y - shu[2 * gen + 1].z + 1] * shu[2 * gen].z2 + shu[2 * gen + 1].z2) % mo2; }}int flag = 0;pair<pair<long long,long long>, long long> xunw(int gen, int zuo, int you, int wz, int wy){ if (zuo > wy || you < wz)return make_pair(make_pair(-1, -1),0); if (zuo >= wz&&you <= wy)return make_pair(make_pair(shu[gen].z1, shu[gen].z2),you-zuo+1); int mid = (zuo + you) / 2; if (shu[gen].lazy != -1) { shu[2 * gen].lazy = shu[2 * gen + 1].lazy = shu[gen].lazy; shu[gen].lazy = -1; shu[2 * gen].z1 = (shu[2 * gen].lazy*s1[shu[2 * gen].y - shu[2 * gen].z]) % mo1; shu[2 * gen].z2 = (shu[2 * gen].lazy*s2[shu[2 * gen].y - shu[2 * gen].z]) % mo2; shu[2 * gen + 1].z1 = (shu[2 * gen].lazy*s1[shu[2 * gen + 1].y - shu[2 * gen + 1].z]) % mo1; shu[2 * gen + 1].z2 = (shu[2 * gen].lazy*s2[shu[2 * gen + 1].y - shu[2 * gen + 1].z]) % mo2; } pair<pair<long long, long long>, long long>zz = xunw(2 * gen, zuo, mid, wz, wy); pair<pair<long long, long long>, long long>yy = xunw(2 * gen + 1, mid + 1, you, wz, wy); if (zz.first.first == -1)return yy; if (yy.first.first == -1)return zz; int youc = yy.second; return make_pair(make_pair((zz.first.first*p1[youc] + yy.first.first) % mo1, (zz.first.second*p2[youc] + yy.first.second) % mo2),zz.second+yy.second);}int main(){ int n, m, k; cin >> n >> m >> k; cin >> q; p1[0] = p2[0] = s1[0] = s2[0] = 1; for (int a = 1;a <= q.size();a++) { p1[a] = p1[a - 1] * bas%mo1; s1[a] = (s1[a - 1] + p1[a]) % mo1; p2[a] = p2[a - 1] * bas%mo2; s2[a] = (s2[a - 1] + p2[a]) % mo2; } int r, t, y, u; jian(1, 1, q.size()); for (int a = 1;a <= m + k;a++) { scanf("%d%d%d%d", &r, &t, &y, &u); if (r == 1)gengxin(1, 1, q.size(), t, y, u); else { if (y - t + 1 == u) { cout << "YES" << endl; continue; } pair<pair<long long, long long>, long long> qwe = xunw(1, 1, q.size(), t, y - u); pair<pair<long long, long long>, long long> wer = xunw(1, 1, q.size(), t+u, y); if (qwe.first.first == wer.first.first&&qwe.first.second == wer.first.second)cout << "YES" << endl; else cout << "NO" << endl; } } return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
欧洲午夜精品久久久| 中文字幕亚洲综合| 国产精品视频免费在线观看| 国产精品成人一区二区| 欧美综合一区第一页| 久久久久久网址| 精品一区二区三区电影| 亚洲视频在线视频| www.午夜精品| 国产免费一区视频观看免费| 国产精品久久久久久av福利| 91九色视频导航| 国产精品久久久久91| xvideos成人免费中文版| 日韩av在线网页| 一本一本久久a久久精品牛牛影视| 欧美精品videos另类日本| 欧美xxxx做受欧美| 2019日本中文字幕| 91精品91久久久久久| 欧美大全免费观看电视剧大泉洋| 5278欧美一区二区三区| 国产91在线播放九色快色| 亚洲成人激情图| 久久国产精品首页| 国产精品一区久久久| 国内精品久久影院| 欧美日产国产成人免费图片| 国产亚洲精品一区二区| 欧美综合国产精品久久丁香| 亚洲精品自拍偷拍| 国产欧美日韩高清| 日韩欧美中文字幕在线播放| 久久视频这里只有精品| 欧美一区二区三区艳史| 欧美激情在线观看| 国产精品第10页| 亚洲性av在线| 在线观看国产精品日韩av| 国产欧美精品久久久| 不用播放器成人网| 久久久av网站| 国产一区二中文字幕在线看| 最近2019好看的中文字幕免费| 成人免费黄色网| 久久99久久久久久久噜噜| 久久精品一本久久99精品| 亚洲国产精品系列| 国产色婷婷国产综合在线理论片a| 538国产精品一区二区在线| 欧美综合激情网| 97久久久久久| 亚洲国产日韩精品在线| 91精品国产精品| 久久久久久久久久久久久久久久久久av| 国产日韩在线看片| 日韩二区三区在线| 日韩欧美中文免费| 91香蕉电影院| 欧洲亚洲免费视频| 国产成人福利夜色影视| 亚洲第一男人天堂| 亚洲国产欧美精品| 热草久综合在线| 亚洲人免费视频| 青草青草久热精品视频在线网站| 国产精品久久一区主播| 欧美黑人一区二区三区| 欧美一级免费视频| 欧美精品18videosex性欧美| 亚洲一二在线观看| 97在线日本国产| 91久久久久久久| 黑人巨大精品欧美一区二区一视频| 国产精品大片wwwwww| 国产在线视频欧美| 国产亚洲欧洲黄色| 日韩国产精品亚洲а∨天堂免| 国产精品亚洲激情| 欧美最猛性xxxxx(亚洲精品)| 亚洲日本aⅴ片在线观看香蕉| 久久综合伊人77777尤物| 欧美色欧美亚洲高清在线视频| 欧美激情videoshd| 国产香蕉精品视频一区二区三区| 国产日韩中文字幕| 欧美日韩国产影院| 日韩hd视频在线观看| 日韩av手机在线看| 欧美在线性视频| 日韩久久精品电影| 超碰日本道色综合久久综合| 黑人巨大精品欧美一区免费视频| 欧美在线视频观看免费网站| 中文字幕在线日韩| 国产免费一区视频观看免费| 国产精品日韩电影| 成人免费看吃奶视频网站| 国产一区私人高清影院| 国产精品爽黄69| 欧美日韩免费看| 日韩视频欧美视频| 国模精品视频一区二区| 久久久精品美女| 国产91精品在线播放| 国产精品久久久久久久av大片| 永久免费毛片在线播放不卡| 91在线无精精品一区二区| 亚洲美女视频网| www.欧美三级电影.com| 亚洲国产精品久久久久秋霞蜜臀| 亚洲免费视频一区二区| 55夜色66夜色国产精品视频| 自拍偷拍免费精品| 日本19禁啪啪免费观看www| 欧美在线性爱视频| 成人av在线网址| 亚洲精品综合久久中文字幕| 国产精品成久久久久三级| 亚洲性无码av在线| 久久国产精品久久精品| 国产亚洲精品高潮| 精品久久香蕉国产线看观看亚洲| 久久伊人色综合| 深夜成人在线观看| 黄色一区二区三区| www.欧美三级电影.com| 国产网站欧美日韩免费精品在线观看| 欧美亚洲国产视频小说| 亚洲精品98久久久久久中文字幕| 日韩精品视频在线播放| 2020久久国产精品| 国产小视频91| 亚洲最大av网| 日韩美女福利视频| 国产精品96久久久久久又黄又硬| 久久精品国产免费观看| 久久久精品电影| 欧美性生交xxxxx久久久| www.久久色.com| 欧美高清第一页| 国产一区二区丝袜高跟鞋图片| 久久伊人精品视频| 色偷偷av亚洲男人的天堂| 中文字幕精品影院| 久久av在线看| 日韩av电影在线网| 国产精品日韩精品| 大桥未久av一区二区三区| 91tv亚洲精品香蕉国产一区7ujn| 97在线观看视频国产| 成人激情视频在线观看| 亚洲精品v欧美精品v日韩精品| 国产不卡av在线| 26uuu国产精品视频| 不用播放器成人网| 另类专区欧美制服同性| 亚洲人成欧美中文字幕| 欧美色图在线视频| 亚洲一区二区三区777| 亚洲加勒比久久88色综合| 欧美网站在线观看| 欧美久久精品一级黑人c片| 亚洲无限av看|