結果

問題 No.3239 Omnibus
ユーザー lif4635
提出日時 2025-08-15 23:47:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 2,486 bytes
コンパイル時間 3,834 ms
コンパイル使用メモリ 253,728 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-15 23:50:08
合計ジャッジ時間 158,991 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30 TLE * 1 -- * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
// using mint = modint1000000007;
// using mint = double;
#endif

//define
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long , long long>;
using vi = vector<int>;
using vll = vector<long long>;

#define rep(i,l,r) for (int i = (int)(l); i < (int)(r); i++)
#define rrep(i,l,r) for (int i = (int)(r-1); i >= (int)(l); i--)
#define len(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define elif else if
const int inf = 1e9;
const long long infl = 1LL<<60;
const int mod = 998244353;
ll pow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
template<class T, class U> bool chmin(T& a, const U& b){ if(a > T(b)){ a = b; return 1; } return 0; }
template<class T, class U> bool chmax(T& a, const U& b){ if(a < T(b)){ a = b; return 1; } return 0; }
template <class T>
using spq = priority_queue<T, vector<T>, greater<T>>;

template<class T>istream& operator>>(istream& i, vector<T>& v) {for(int j = 0; j < (int)(v).size(); j++) i >> v[j]; return i;}
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        cerr << fixed << setprecision(15);
    }
} iosetup;


int main(){
    int n, q; cin >> n >> q;
    string s; cin >> s;
    while(q--){
        int t; cin >> t;
        if (t == 1){
            int k; char x; cin >> k >> x;
            s[k-1] = x;
        }else if(t == 2){
            int l, r; string a; cin >> l >> r >> a;
            char a0 = a[0], a1 = a[1], a2 = a[2];
            ll ans = 0;
            if (a0 == a1 and a1 == a2){
                for (int i = l-1; i < r-2; i++){
                    if (s[i+2] != a2){
                        i += 2;
                    }else if (s[i+1] != a1){
                        i += 1;
                    }else if (s[i] != a0){
                        ;
                    }else{
                        ans += i - l + 2;
                    }
                }
            }else{
                for (int i = l-1; i < r-2; i++){
                    if (s[i] == a0 and s[i+1] == a1 and s[i+2] == a2){
                        ans += i - l + 2;
                    }
                }
            }
            cout << ans << "\n";
        }
    }
    return 0;
}
0