結果

問題 No.1725 [Cherry 3rd Tune D] 無言の言葉
ユーザー 👑 tatyamtatyam
提出日時 2021-10-16 18:09:51
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 225 ms / 4,000 ms
コード長 1,113 bytes
コンパイル時間 3,690 ms
コンパイル使用メモリ 282,228 KB
実行使用メモリ 50,328 KB
最終ジャッジ日時 2024-04-16 13:46:59
合計ジャッジ時間 9,409 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 3 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 11 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 17 ms
6,144 KB
testcase_14 AC 117 ms
6,144 KB
testcase_15 AC 19 ms
6,656 KB
testcase_16 AC 26 ms
7,016 KB
testcase_17 AC 46 ms
7,212 KB
testcase_18 AC 135 ms
5,632 KB
testcase_19 AC 37 ms
5,376 KB
testcase_20 AC 14 ms
5,376 KB
testcase_21 AC 121 ms
5,376 KB
testcase_22 AC 143 ms
18,392 KB
testcase_23 AC 146 ms
16,648 KB
testcase_24 AC 98 ms
13,248 KB
testcase_25 AC 170 ms
26,692 KB
testcase_26 AC 142 ms
21,388 KB
testcase_27 AC 134 ms
30,168 KB
testcase_28 AC 196 ms
28,608 KB
testcase_29 AC 190 ms
27,472 KB
testcase_30 AC 172 ms
32,620 KB
testcase_31 AC 108 ms
16,584 KB
testcase_32 AC 221 ms
43,644 KB
testcase_33 AC 225 ms
45,188 KB
testcase_34 AC 215 ms
41,720 KB
testcase_35 AC 213 ms
37,220 KB
testcase_36 AC 218 ms
41,200 KB
testcase_37 AC 160 ms
5,376 KB
testcase_38 AC 158 ms
5,376 KB
testcase_39 AC 157 ms
5,376 KB
testcase_40 AC 158 ms
5,376 KB
testcase_41 AC 157 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 57 ms
50,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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