結果

問題 No.2626 Similar But Different Name
ユーザー Carpenters-Cat
提出日時 2024-02-10 20:55:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 225 ms / 3,000 ms
コード長 772 bytes
コンパイル時間 4,570 ms
コンパイル使用メモリ 258,368 KB
最終ジャッジ日時 2025-02-19 04:44:25
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
int main () {
	int N, M, K;
	cin >> N >> M >> K;
	string s, t;
	cin >> s >> t;
	string x = t + s;
	for (auto& a : x) {
		if ('A' <= a && a <= 'Z') {
			a = a + 'a' - 'A';
		}
	}
	auto v = z_algorithm(x);
	std::vector<long long> s1(N, 0), s2(N, 0), t1(M, 0), t2(M, 0);
	for (int i = 0; i < N; i ++) {
		('A' <= s[i] && s[i] <= 'Z' ? s1 : s2)[i] ++;
	}
	for (int i = 0; i < M; i ++) {
		('A' <= t[i] && t[i] <= 'Z' ? t1 : t2)[M - i - 1] ++;
	}
	auto c1 = convolution(s1, t2);
	auto c2 = convolution(s2, t1);
	int ans = 0;
	for (int i = 0; i + M <= N; i ++) {
		int c = (c1[i + M - 1] + c2[i + M - 1]);
		ans += ((v[i + M] >= M) && (1 <= c) && (c <= K));
	}
	cout << ans << endl;
}
0