結果

問題 No.2554 MMA文字列2 (Query Version)
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2024-03-09 17:15:06
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,906 bytes
コンパイル時間 8,867 ms
コンパイル使用メモリ 351,060 KB
実行使用メモリ 813,524 KB
最終ジャッジ日時 2024-03-09 17:15:19
合計ジャッジ時間 10,695 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 9 ms
6,676 KB
testcase_03 AC 12 ms
6,676 KB
testcase_04 AC 22 ms
20,372 KB
testcase_05 AC 18 ms
20,372 KB
testcase_06 AC 13 ms
11,088 KB
testcase_07 AC 12 ms
6,676 KB
testcase_08 AC 13 ms
18,324 KB
testcase_09 AC 19 ms
20,372 KB
testcase_10 AC 19 ms
18,324 KB
testcase_11 AC 9 ms
7,320 KB
testcase_12 AC 166 ms
261,632 KB
testcase_13 MLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <atcoder/all>


using namespace std;
using namespace atcoder;
#define rep(i,m,n,k) for (int i = (int)(m); i < (int)(n); i += (int)(k))
#define rrep(i,m,n,k) for (int i = (int)(m); i > (int)(n); i += (int)(k))
#define ll long long
#define list(T,A,N) vector<T> A(N);for(int i=0;i<(int)(N);i++){cin >> A[i];}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
// #define int long long
constexpr int L = 26*27+1;
constexpr int M = 26;

array<ll,L> op( array<ll,L> x,array<ll,L> y){

    array<ll,L> z;
    rep(i,0,L,1){
        z[i] = x[i]+y[i];
    }
    rep(i,0,M,1){
        rep(j,0,M,1){
            if(i!=j){
                z[L-1] = (z[L-1]
                        + x[i]*y[M*(i+1)+j] 
                        + x[M*(i+1)+i]*y[j]);
                        }
            z[M*(i+1)+j] = z[M*(i+1)+j] + x[i]*y[j];
        }
    }
    return z;
}

array<ll,L> e(){
    array<ll,L> z;
    rep(i,0,L,1){
        z[i] = 0;
    }
    return z;
}
array<ll,L> conv(char s){
    
    array<ll,L> z;
    rep(i,0,L,1){
        z[i] = 0;
    }
    z[s-'A'] = 1;
    return z;
}

int main(){
    // ios::sync_with_stdio(false);
    // std::cin.tie(nullptr);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    vector<array<ll,L>> I;
    for(auto s:S){
        I.push_back(conv(s));
    }
    segtree<array<ll,L>,op,e> T(I);
    int t,x,l,r;
    char c;
    rep(_,0,Q,1){
        cin >> t;
        if(t==1){
            cin >> x >> c;
            x -= 1;
            T.set(x,conv(c));
        }
        else{
            cin >> l >> r;
            l -= 1;
            cout << T.prod(l,r)[L-1] << "\n";
        }
    }
    return 0;

}


0