結果

問題 No.2626 Similar But Different Name
ユーザー umimelumimel
提出日時 2024-02-09 22:28:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,849 bytes
コンパイル時間 3,201 ms
コンパイル使用メモリ 212,120 KB
実行使用メモリ 32,936 KB
最終ジャッジ日時 2024-02-09 22:28:15
合計ジャッジ時間 5,618 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,676 KB
testcase_05 WA -
testcase_06 AC 1 ms
6,676 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 WA -
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 87 ms
32,936 KB
testcase_19 WA -
testcase_20 AC 19 ms
18,112 KB
testcase_21 AC 18 ms
18,112 KB
testcase_22 AC 86 ms
26,432 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 87 ms
26,664 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 84 ms
25,408 KB
testcase_31 AC 87 ms
26,200 KB
testcase_32 WA -
testcase_33 AC 85 ms
26,664 KB
testcase_34 WA -
testcase_35 AC 85 ms
26,244 KB
testcase_36 WA -
testcase_37 AC 85 ms
32,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const ll MOD1000000007 = 1000000007;
const ll MOD998244353 = 998244353;
const ll MOD[3] = {999727999, 1070777777, 1000000007};
const ll LINF = 1LL << 60LL;
const int IINF = (1 << 30) - 1;


vector<int> z_algorithm(string s){
    int n = (int)s.size();
    vector<int> z(n);
    z[0] = n;
    int i=1, j=0;
    while(i < n){
        while(i+j<n && s[j]==s[i+j]) j++;
        z[i] = j;

        if(j == 0){
            i++;
            continue;
        }

        int k=1;
        while(k < j && k+z[k]<j){
            z[i+k] = z[k];
            k++;
        }
        i += k;
        j -= k;
    }

    return z;
}

#include <atcoder/convolution>
using namespace atcoder;

void solve(){
    ll n, m, k; cin >> n >> m >> k;
    string s, t; cin >> s >> t;
    vector<ll> a(n, -1), b(m, -1);
    for(ll i=0; i<n; i++){
        if('A'<=s[i] && s[i]<='Z'){
            s[i] = (char)('a' + (ll)(s[i]-'A'));
            a[i] = 1;
        }
    }
    for(ll i=0; i<m; i++){
        if('A'<=t[i] && t[i]<='Z'){
            t[i] = (char)('a' + (ll)(t[i]-'A'));
            b[i] = 1;
        }
    }

    string r = t+s;
    vector<int> z = z_algorithm(r);

    reverse(all(b));
    vector<ll> c = convolution(a, b);

    ll ans = 0;
    rep(i, n){
        if(z[m+i]<m) continue;
        ll cnt = (m-c[m-1+i])/2;
        if(1<=cnt&&cnt<=k) ans++;
    }
    cout << ans << '\n';
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int T=1;
    //cin >> T;
    while(T--) solve();
}
0