Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <math.h>
- #include <string>
- #include <set>
- #include <cstdio>
- #include <iomanip>
- #include <map>
- #include <stdio.h>
- #include <math.h>
- #include <queue>
- #include <random>
- using namespace std;
- #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- int gcd(int a, int b) { return b ? a : gcd(b, a % b); }
- int toNum(char s) {
- return s - 'a';
- }
- const int INF = 1e10;
- //#pragma GCC optimize("Ofast")
- //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- long long n,k,q,l,r;
- double mi;
- char kek;
- string quest;
- int a[100000];
- bool isPalindrom(int left, int right) {
- if (left == right)
- return 1;
- if ((right - left) % 2 == 0) {
- while (right - left != 2) {
- if (a[left] != a[right])
- return 0;
- left++;
- right--;
- }
- }
- else {
- while (right - left != 1) {
- if (a[left] != a[right])
- return 0;
- left++;
- right--;
- }
- }
- return 1;
- }
- void change(int left, int right, int z) {
- for (int i = left; i <= right; i++)
- a[i] = z;
- }
- int main() {
- //freopen("sum.in", "r", stdin);
- //freopen("sum.out", "w", stdout);
- IOS;
- cin >> n >> q;
- for (int i = 0; i < n; i++) {
- cin >> kek;
- a[i] = toNum(kek);
- }
- for (int i = 0; i < q; i++) {
- cin >> quest;
- if (quest == "ask") {
- cin >> l >> r;
- if (isPalindrom(l - 1, r - 1))
- cout << "YES" << "\n";
- else
- cout << "NO" << "\n";
- }
- else {
- cin >> l >> r >> kek;
- change(l - 1, r - 1, toNum(kek));
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement