結果

問題 No.3638 Itsuki
コンテスト
ユーザー GOTKAKO
提出日時 2026-08-28 01:02:39
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 138 ms / 3,000 ms
+ 712µs
コード長 1,438 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,199 ms
コンパイル使用メモリ 213,684 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-28 01:02:43
合計ジャッジ時間 4,089 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
サンプル 0 % AC * 2
小課題1 10 % AC * 5
小課題2 50 % AC * 6
小課題3 40 % AC * 18
合計 100 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

template<typename T>
vector<int> Zalgo(const vector<T> &s){
    int l1 = 0,N = s.size();
    vector<int> ret(N);
    for(int i=1; i<N; i++){
        int l2 = i-l1;
        if(i+ret.at(l2) < l1+ret.at(l1)) ret.at(i) = ret.at(l2);
        else{
            int len = max(0,l1+ret.at(l1)-i);
            while(i+len < N && s.at(len) == s.at(i+len)) len++;
            ret.at(i) = len; l1 = i;
        }
    }
    ret.at(0) = N;
    return ret;
}
vector<int> Zalgo(const string &s){
    int l1 = 0,N = s.size();
    vector<int> ret(N);
    for(int i=1; i<N; i++){
        int l2 = i-l1;
        if(i+ret.at(l2) < l1+ret.at(l1)) ret.at(i) = ret.at(l2);
        else{
            int len = max(0,l1+ret.at(l1)-i);
            while(i+len < N && s.at(len) == s.at(i+len)) len++;
            ret.at(i) = len; l1 = i;
        }
    }
    ret.at(0) = N;
    return ret;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N,Q; cin >> N >> Q;
    string s; cin >> s;
    while(Q--){
        int type; cin >> type;
        if(type == 1){
            int pos; char c; cin >> pos >> c,pos--;
            s.at(pos) = c;
        }
        else{
            string t; cin >> t;
            auto Z = Zalgo(t+'-'+s);
            bool yes = false;
            for(int i=1; i<Z.size(); i++) yes |= Z.at(i)==t.size();
            cout << (yes?"Yes\n":"No\n");
        }
    }
}
0