結果

問題 No.1725 [Cherry 3rd Tune D] 無言の言葉
ユーザー 👑 tatyamtatyam
提出日時 2021-10-29 23:30:43
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 219 ms / 4,000 ms
コード長 964 bytes
コンパイル時間 3,739 ms
コンパイル使用メモリ 283,932 KB
実行使用メモリ 50,328 KB
最終ジャッジ日時 2024-04-16 15:58:33
合計ジャッジ時間 9,502 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 5 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 13 ms
6,940 KB
testcase_07 AC 6 ms
6,940 KB
testcase_08 AC 10 ms
6,944 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 6 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 15 ms
6,940 KB
testcase_13 AC 17 ms
6,944 KB
testcase_14 AC 114 ms
6,940 KB
testcase_15 AC 19 ms
6,940 KB
testcase_16 AC 26 ms
6,944 KB
testcase_17 AC 45 ms
7,208 KB
testcase_18 AC 138 ms
6,944 KB
testcase_19 AC 38 ms
6,944 KB
testcase_20 AC 15 ms
6,944 KB
testcase_21 AC 122 ms
6,940 KB
testcase_22 AC 146 ms
18,268 KB
testcase_23 AC 143 ms
16,652 KB
testcase_24 AC 97 ms
13,116 KB
testcase_25 AC 172 ms
26,692 KB
testcase_26 AC 140 ms
21,384 KB
testcase_27 AC 133 ms
30,040 KB
testcase_28 AC 196 ms
28,608 KB
testcase_29 AC 188 ms
27,332 KB
testcase_30 AC 173 ms
32,724 KB
testcase_31 AC 108 ms
16,656 KB
testcase_32 AC 219 ms
43,644 KB
testcase_33 AC 219 ms
45,056 KB
testcase_34 AC 218 ms
41,844 KB
testcase_35 AC 212 ms
37,344 KB
testcase_36 AC 212 ms
41,072 KB
testcase_37 AC 159 ms
6,944 KB
testcase_38 AC 157 ms
6,944 KB
testcase_39 AC 158 ms
6,944 KB
testcase_40 AC 159 ms
6,940 KB
testcase_41 AC 157 ms
6,940 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 60 ms
50,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using A = valarray<i64>;

int main(){
	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