結果

問題 No.1725 [Cherry 3rd Tune D] 無言の言葉
ユーザー 👑 tatyamtatyam
提出日時 2021-10-16 18:01:44
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 222 ms / 4,000 ms
コード長 1,138 bytes
コンパイル時間 3,759 ms
コンパイル使用メモリ 282,200 KB
実行使用メモリ 50,328 KB
最終ジャッジ日時 2024-04-16 13:46:49
合計ジャッジ時間 11,001 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 14 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 10 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 16 ms
6,016 KB
testcase_13 AC 16 ms
6,016 KB
testcase_14 AC 117 ms
6,144 KB
testcase_15 AC 19 ms
6,508 KB
testcase_16 AC 27 ms
6,884 KB
testcase_17 AC 46 ms
7,336 KB
testcase_18 AC 139 ms
5,632 KB
testcase_19 AC 38 ms
5,376 KB
testcase_20 AC 15 ms
5,376 KB
testcase_21 AC 124 ms
5,376 KB
testcase_22 AC 144 ms
18,388 KB
testcase_23 AC 142 ms
16,652 KB
testcase_24 AC 99 ms
13,168 KB
testcase_25 AC 172 ms
26,684 KB
testcase_26 AC 141 ms
21,384 KB
testcase_27 AC 131 ms
30,040 KB
testcase_28 AC 196 ms
28,740 KB
testcase_29 AC 191 ms
27,336 KB
testcase_30 AC 170 ms
32,600 KB
testcase_31 AC 107 ms
16,780 KB
testcase_32 AC 218 ms
43,644 KB
testcase_33 AC 222 ms
45,056 KB
testcase_34 AC 216 ms
41,720 KB
testcase_35 AC 214 ms
37,348 KB
testcase_36 AC 216 ms
41,076 KB
testcase_37 AC 158 ms
5,376 KB
testcase_38 AC 159 ms
5,376 KB
testcase_39 AC 158 ms
5,376 KB
testcase_40 AC 158 ms
5,376 KB
testcase_41 AC 161 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 57 ms
50,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma optimize("avx2")
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;


int main(){
    using A = valarray<i64>;
    string X, Y;
    cin >> X >> Y;
    A countX(i64{}, 27), countY(i64{}, 27);
    vector<A> accX = {countX}, accY = {countY};
    for(char& c : X){
        countX[c -= 'a']++;
        countX[26]++;
        accX.push_back(countX);
    }
    for(char& c : Y){
        countY[c -= 'a']++;
        countY[26]++;
        accY.push_back(countY);
    }
    vector<A> countF = {countX};
    for(i64 i = 0; i < 30; i++) countF.push_back(countF.back() * 2 + countY);
    function<i64(i64, i64, char)> count = [&](i64 N, i64 R, char C){
        if(N == 0) return accX[R][C];
        if(R < countF[N - 1][26]) return count(N - 1, R, C);
        if(R > countF[N - 1][26] + Y.size()) return countF[N][C] - count(N - 1, countF[N][26] - R, C);
        return countF[N - 1][C] + accY[R - countF[N - 1][26]][C];
    };
    i64 Q;
    cin >> Q;
    while(Q--){
        i64 L, R;
        char C;
        cin >> L >> R >> C;
        L--;
        C -= 'a';
        cout << count(30, R, C) - count(30, L, C) << '\n';
    }
}
0