結果

問題 No.1725 [Cherry 3rd Tune D] 無言の言葉
ユーザー 👑 tatyamtatyam
提出日時 2021-10-29 23:35:16
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 249 ms / 4,000 ms
コード長 935 bytes
コンパイル時間 3,617 ms
コンパイル使用メモリ 282,864 KB
実行使用メモリ 50,332 KB
最終ジャッジ日時 2024-04-16 16:00:10
合計ジャッジ時間 10,002 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 15 ms
5,376 KB
testcase_07 AC 7 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 17 ms
6,144 KB
testcase_13 AC 17 ms
6,272 KB
testcase_14 AC 129 ms
6,272 KB
testcase_15 AC 21 ms
6,528 KB
testcase_16 AC 27 ms
6,944 KB
testcase_17 AC 48 ms
7,336 KB
testcase_18 AC 154 ms
5,632 KB
testcase_19 AC 41 ms
5,376 KB
testcase_20 AC 16 ms
5,376 KB
testcase_21 AC 139 ms
5,376 KB
testcase_22 AC 169 ms
18,392 KB
testcase_23 AC 169 ms
16,908 KB
testcase_24 AC 115 ms
13,116 KB
testcase_25 AC 199 ms
26,820 KB
testcase_26 AC 165 ms
21,388 KB
testcase_27 AC 151 ms
30,172 KB
testcase_28 AC 226 ms
28,860 KB
testcase_29 AC 216 ms
27,340 KB
testcase_30 AC 194 ms
32,600 KB
testcase_31 AC 127 ms
16,780 KB
testcase_32 AC 246 ms
43,896 KB
testcase_33 AC 249 ms
45,188 KB
testcase_34 AC 246 ms
41,720 KB
testcase_35 AC 242 ms
37,212 KB
testcase_36 AC 244 ms
41,076 KB
testcase_37 AC 222 ms
5,376 KB
testcase_38 AC 225 ms
5,376 KB
testcase_39 AC 222 ms
5,376 KB
testcase_40 AC 221 ms
5,376 KB
testcase_41 AC 222 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 55 ms
50,332 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<A(i64, i64)> count = [&](i64 N, i64 R) -> A {
		if(N == 0) return accX[R];
		if(R < countF[N - 1][26]) return count(N - 1, R);
		if(R > countF[N - 1][26] + Y.size()) return countF[N] - count(N - 1, countF[N][26] - R);
		return countF[N - 1] + accY[R - countF[N - 1][26]];
	};
	i64 Q;
	cin >> Q;
	while(Q--){
		i64 L, R;
		char C;
		cin >> L >> R >> C;
		L--;
		C -= 'a';
		cout << (count(30, R) - count(30, L))[C] << '\n';
	}
}
0