結果

問題 No.3638 Itsuki
コンテスト
ユーザー Yoyoyo8128
提出日時 2026-08-25 16:06:08
言語 C++23(gnu拡張)
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 10,834 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,173 ms
コンパイル使用メモリ 408,600 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-25 16:06:23
合計ジャッジ時間 8,832 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
サンプル 0 % AC * 2
小課題1 10 % AC * 4 WA * 1
小課題2 50 % AC * 5 RE * 1
小課題3 40 % AC * 16 WA * 1 RE * 1
合計 0 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma region Yoyoyo

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
#ifndef LOCAL
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
using namespace std;
using ll = long long;
using ld = long double;
using i128t = __int128_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const string Yes = "Yes";
const string No = "No";
const string YES = "YES";
const string NO = "NO";
const ll MOD = 1000000007;
const ll mod = 998244353;
const long long inf = 1ll << 60;
const int inft = 1e9;
const long double PI = 3.1415926535897932384626;
const vector<int> dx = {0, 1, 0, -1, 1, -1, -1, 1};
const vector<int> dy = {1, 0, -1, 0, 1, 1, -1, -1};
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define faster ios::sync_with_stdio(false);cin.tie(nullptr);
#define print(s) cout << s << "\n";

#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using Mint = modint1000000007;
using pint = modint;
#endif

#define YESNO(T){              \
    if (T){                    \
        cout << "YES" << "\n"; \
    }else{                     \
        cout << "NO" << "\n";  \
    }                          \
}
#define yesno(T){              \
    if (T){                    \
        cout << "yes" << "\n"; \
    }else{                     \
        cout << "no" << "\n";  \
    }                          \
}
#define YesNo(T){              \
    if (T){                    \
        cout << "Yes" << "\n"; \
    }else{                     \
        cout << "No" << "\n";  \
    }                          \
}

template <typename T>
inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template <typename T>
inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
template <class T>
auto sum(const vector<T> &a){
    T ans = 0;
    for(auto e : a)ans += e;
    return ans;
}

// pair_out
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
    os << p.first << " " << p.second;
    return os;
}
// pair_in
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p){
    is >> p.first >> p.second;
    return is;
}
// vector_out
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
    int s = (int)v.size();
    for (int i = 0; i < s; i++){
        os << (i ? " " : "") << v[i];
    }
    return os;
}
// vector_in
template <typename T>
istream &operator>>(istream &is, vector<T> &v){
    for (auto &x : v)is >> x;
    return is;
}
//__int128_t_in
istream &operator>>(istream &is, __int128_t &x){
    string S;
    is >> S;
    x = 0;
    int flag = 0;
    for (auto &c : S){
        if (c == '-'){
            flag = true;
            continue;
        }
        x *= 10;
        x += c - '0';
    }
    if (flag)x = -x;
    return is;
}
//__uint128_t_in
istream &operator>>(istream &is, __uint128_t &x){
    string S;
    is >> S;
    x = 0;
    for (auto &c : S){
        x *= 10;
        x += c - '0';
    }
    return is;
}
//__int128_t_out
ostream &operator<<(ostream &os, __int128_t x){
    if (x == 0)return os << 0;
    if (x < 0)os << '-', x = -x;
    string S;
    while (x){
        S.push_back('0' + x % 10), x /= 10;
    }
    reverse(begin(S), end(S));
    return os << S;
}
//__uint128_t_out
ostream &operator<<(ostream &os, __uint128_t x)
{
    if (x == 0)return os << 0;
    string S;
    while (x){
        S.push_back('0' + x % 10), x /= 10;
    }
    reverse(begin(S), end(S));
    return os << S;
}
// vector<vector>_out
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v){
    for (int i = 0; i < (int)v.size(); i++){
        os << v[i] << "\n";
    }
    return os;
}
// vector<vector<vector>>_out
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<vector<T>>> &v){
    for (int i = 0; i < (int)v.size(); i++){
        os << "i = " << i << "\n";
        os << v[i];
    }
    return os;
}
// map_out
template <typename T, typename S>
ostream &operator<<(ostream &os, const map<T, S> &m){
    for (auto &[key, val] : m){
        os << key << ":" << val << " ";
    }
    return os;
}
// set_out
template <typename T>
ostream &operator<<(ostream &os, const set<T> &st){
    auto itr = st.begin();
    for (int i = 0; i < (int)st.size(); i++){
        os << *itr << (i + 1 != (int)st.size() ? " " : "");
        itr++;
    }
    return os;
}
// multiset_out
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &st){
    auto itr = st.begin();
    for (int i = 0; i < (int)st.size(); i++){
        os << *itr << (i + 1 != (int)st.size() ? " " : "");
        itr++;
    }
    return os;
}
// queue_out
template <typename T>
ostream &operator<<(ostream &os, queue<T> q){
    while (q.size()){
        os << q.front() << " ";
        q.pop();
    }
    return os;
}
// deque_out
template <typename T>
ostream &operator<<(ostream &os, deque<T> q){
    while (q.size()){
        os << q.front() << " ";
        q.pop_front();
    }
    return os;
}
// stack_out
template <typename T>
ostream &operator<<(ostream &os, stack<T> st){
    while (st.size()){
        os << st.top() << " ";
        st.pop();
    }
    return os;
}
// priority_queue_out
template <class T, class Container, class Compare>
ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq){
    while (pq.size()){
        os << pq.top() << " ";
        pq.pop();
    }
    return os;
}

#if __has_include(<atcoder/all>)
// 998244353_in
istream &operator>>(istream &is, mint &b){
    long long tmp;
    is >> tmp;
    b = tmp;
    return is;
}
// 998244353_out
ostream &operator<<(ostream &os, mint &b){
    os << b.val();
    return os;
}
// 1000000007_in
istream &operator>>(istream &is, Mint &b){
    long long tmp;
    is >> tmp;
    b = tmp;
    return is;
}
// 1000000007_out
ostream &operator<<(ostream &os, Mint &b){
    os << b.val();
    return os;
}
// 998244353_vin
istream &operator>>(istream &is, vector<mint> &b){
    for (auto &e : b){
        long long tmp;
        is >> tmp;
        e = tmp;
    }
    return is;
}
// 998244353_vout
ostream &operator<<(ostream &os, vector<mint> &b){
    int s = b.size();
    for (int i = 0; i < s; i++){
        os << (i ? " " : "") << b[i].val();
    }
    return os;
}
// 1000000007_vin
istream &operator>>(istream &is, vector<Mint> &b){
    for (auto &e : b){
        long long tmp;
        is >> tmp;
        e = tmp;
    }
    return is;
}
// 1000000007_vout
ostream &operator<<(ostream &os, vector<Mint> &b){
    int s = b.size();
    for (int i = 0; i < s; i++){
        os << (i ? " " : "") << b[i].val();
    }
    return os;
}
#endif

#ifdef LOCAL
template <class... Args>
void debug_out(Args... args){
    int _i = 0;
    ((cerr << (_i++ ? ", " : " ") << args), ...);
    cerr << "\n";
}
#define debug(...){                      \
    cerr << "[" << #__VA_ARGS__ << "]:"; \
    debug_out(__VA_ARGS__);              \
}
#else
#define debug(...)
#endif

#pragma endregion Yoyoyo



struct RollingHash {
    using ull = unsigned long long;
    static const ull mod = (1ULL << 61) - 1;

    static const ull base = 20090926; //My Birthday.

    vector<ull> power;
    vector<ull> hash;

    static ull mul(ull a, ull b) {
        __uint128_t t = (__uint128_t)a * b;
        t = (t >> 61) + (t & mod);
        if (t >= mod) t -= mod;
        return (ull)t;
    }

    static ull add(ull a, ull b) {
        a += b;
        if (a >= mod) a -= mod;
        return a;
    }

    static ull sub(ull a, ull b) {
        a += mod - b;
        if (a >= mod) a -= mod;
        return a;
    }

    RollingHash(const string &s) {
        int n = s.size();
        power.resize(n + 1);
        hash.resize(n + 1);

        power[0] = 1;
        for (int i = 0; i < n; i++) {
            power[i + 1] = mul(power[i], base);
        }

        hash[0] = 0;
        for (int i = 0; i < n; i++) {
            hash[i + 1] = add(mul(hash[i], base), s[i]+1);
        }
    }

    //[l, r)
    ull get(int l, int r) const {
        return sub(hash[r], mul(hash[l], power[r - l]));
    }

    // s[i..] と s[j..] のLCP
    int lcp(int i, int j) const {
        int n = hash.size() - 1;
        int low = 0;
        int high = min(n - i, n - j) + 1;

        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (get(i, i + mid) == get(j, j + mid)) {
                low = mid;
            } else {
                high = mid;
            }
        }
        return low;
    }
};

struct RollingHash_inmu {
    using ull = unsigned long long;
    static const ull mod = 11451445450721;

    static const ull base = 114514; //My Birthday.

    vector<ull> power;
    vector<ull> hash;

    static ull mul(ull a, ull b) {
        __uint128_t t = (__uint128_t)a * b;
        t = (t >> 61) + (t & mod);
        if (t >= mod) t -= mod;
        return (ull)t;
    }

    static ull add(ull a, ull b) {
        a += b;
        if (a >= mod) a -= mod;
        return a;
    }

    static ull sub(ull a, ull b) {
        a += mod - b;
        if (a >= mod) a -= mod;
        return a;
    }

    RollingHash_inmu(const string &s) {
        int n = s.size();
        power.resize(n + 1);
        hash.resize(n + 1);

        power[0] = 1;
        for (int i = 0; i < n; i++) {
            power[i + 1] = mul(power[i], base);
        }

        hash[0] = 0;
        for (int i = 0; i < n; i++) {
            hash[i + 1] = add(mul(hash[i], base), s[i]+1);
        }
    }

    //[l, r)
    ull get(int l, int r) const {
        return sub(hash[r], mul(hash[l], power[r - l]));
    }

    // s[i..] と s[j..] のLCP
    int lcp(int i, int j) const {
        int n = hash.size() - 1;
        int low = 0;
        int high = min(n - i, n - j) + 1;

        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (get(i, i + mid) == get(j, j + mid)) {
                low = mid;
            } else {
                high = mid;
            }
        }
        return low;
    }
};


int main(){
    faster;
    int N,Q;
    cin>>N>>Q;
    string S;
    cin>>S;
    while(Q--){
        int t;cin>>t;
        if(t==1){
            int a;char b;
            cin>>a>>b;
            a--;S[a]=b;
        }else{
            string s;
            cin>>s;
            RollingHash rh1(S);
            RollingHash rh2(s);
            RollingHash_inmu rh3(S),rh4(s);
            bool flg=0;
            int sz=s.size();
            for(int i=0;i<=S.size()-s.size();i++){
                if(rh1.get(i,i+sz)==rh2.get(0,sz)){
                    flg=1;break;
                }
            }
            YesNo(flg);
        }
    }
}
0