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

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

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

2019-11-10 16:46:28
字體:
來源:轉載
供稿:網友

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.亚洲男人天堂| 亚洲字幕在线观看| 欧美亚洲另类制服自拍| 国产成人精品国内自产拍免费看| 欧美激情欧美激情在线五月| 久久久久久12| 亚洲精品一区久久久久久| 青草青草久热精品视频在线网站| 欧美日韩亚洲一区二区| 成人欧美一区二区三区在线| 日韩精品中文字幕有码专区| 中文字幕精品视频| 日韩成人小视频| 欧美性xxxxxxxxx| 国产精品嫩草影院一区二区| 色悠悠国产精品| 国产一区二区三区三区在线观看| 韩国国内大量揄拍精品视频| 日韩成人在线视频网站| 亚洲综合社区网| 亚洲福利视频二区| 中文字幕av一区中文字幕天堂| 国产亚洲a∨片在线观看| 日韩av在线免费看| 久青草国产97香蕉在线视频| 国产亚洲激情在线| 国产在线观看精品一区二区三区| 亚洲欧美成人一区二区在线电影| 国产日本欧美一区二区三区| 亚洲视频日韩精品| 欧美国产在线电影| 亚洲天堂男人天堂女人天堂| 91精品国产777在线观看| 不卡av在线播放| 亚洲人成电影在线播放| 国产精品久久精品| 亚洲精品久久久久久久久| 欧美日韩一区二区在线播放| 欧美亚洲另类激情另类| 狠狠操狠狠色综合网| 国产美女精彩久久| 91在线视频成人| 久久久久久久久久亚洲| 精品亚洲一区二区三区在线播放| 久久亚洲精品中文字幕冲田杏梨| 欧美成人一二三| 91亚洲午夜在线| 欧美小视频在线| 91久久精品美女| 久久精品在线视频| 亚洲欧洲日产国码av系列天堂| 久久久久国产精品一区| 精品偷拍一区二区三区在线看| 在线观看日韩www视频免费| 欧美成人在线免费| 国产精品网站大全| 777午夜精品福利在线观看| 欧美在线视频免费播放| 91中文字幕在线| 亚洲香蕉伊综合在人在线视看| 亚洲人成网站777色婷婷| 成人有码视频在线播放| 深夜福利国产精品| 亚洲无限乱码一二三四麻| 国产午夜精品免费一区二区三区| 欧美另类极品videosbest最新版本| 亚洲精品ady| 国产精品一区二区三区久久久| 日韩av在线免费看| 国产拍精品一二三| 亚洲天堂网站在线观看视频| 色综合久久悠悠| 久久这里只有精品视频首页| 日韩视频免费中文字幕| 国产成人精品免高潮在线观看| 久久久久久久国产精品| 欧美日韩在线看| 中文字幕亚洲一区二区三区| 久久久久国产精品免费| www.亚洲男人天堂| 97色在线视频观看| 国产伦精品一区二区三区精品视频| 欧美一区二三区| 亚洲第一页在线| 91精品久久久久久久久久| 66m—66摸成人免费视频| 亚洲综合中文字幕在线| 亚洲人免费视频| 国产久一一精品| 日韩av在线精品| 亚洲第一精品电影| 国产精品成人av性教育| 性欧美暴力猛交69hd| 欧美怡红院视频一区二区三区| 欧美色播在线播放| 久久中文字幕在线| 成人黄色在线观看| 综合网日日天干夜夜久久| 疯狂做受xxxx高潮欧美日本| www.日韩.com| 午夜美女久久久久爽久久| 欧美日韩免费观看中文| 欧美高清视频在线| 亚洲国产精品一区二区久| 红桃av永久久久| 国产精品视频不卡| 国产在线a不卡| 欧美性猛交xxxxx免费看| 国自产精品手机在线观看视频| 日韩视频在线观看免费| 国产精品高潮视频| 精品国产一区二区三区四区在线观看| 岛国av一区二区三区| 欧美午夜久久久| 亚洲激情中文字幕| 亚洲老头同性xxxxx| 国产精品1区2区在线观看| 中文字幕国内精品| 国产一区二区三区视频免费| zzjj国产精品一区二区| 欧美激情综合色综合啪啪五月| 日韩欧美国产一区二区| 精品久久久久久久久中文字幕| 国产成人精品一区二区在线| 国产精品www网站| 国产日本欧美一区二区三区在线| 欧美大片网站在线观看| 91亚洲国产精品| 欧美性xxxxxx| 亚洲国产精品福利| 91精品视频免费看| 成人免费自拍视频| 亚洲一区二区三区sesese| 一区二区欧美激情| 亚洲精品电影在线| 成人天堂噜噜噜| 日韩av在线免播放器| 久久久精品2019中文字幕神马| 亚洲精品少妇网址| 夜夜嗨av一区二区三区免费区| 日韩精品欧美激情| 国产一区二区三区视频在线观看| 欧美俄罗斯乱妇| 欧美成人午夜视频| 亚洲在线观看视频网站| 中文字幕免费精品一区高清| 一区二区在线视频播放| 日韩激情第一页| 日本中文字幕不卡免费| 亚洲天堂2020| 国产日韩欧美在线| 亚洲成年人在线| 欧美国产日韩二区| 中文字幕亚洲综合| 欧美久久精品一级黑人c片| 欧美日韩一区二区在线| 亲爱的老师9免费观看全集电视剧|