Submission #2135616


Source Code Expand

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
using mint = lli;
lli mod = 1e9 + 7, base = 97;
int main()
{
    string s, t;
    cin >> s >> t;
    lli v = 0, e = 1;
    rep(i, t.size())
    {
        v = v * base + s[i] - 'a';
        v %= mod;
    }
    rep(i, t.size() - 1)(e *= base) %= mod;
    map<int, int> st;
    for (lli i = t.size(); i < s.size() + 1; i++) {
        st[v]++;
        //    st.insert(v);
        //cout << v << endl;
        if (i == s.size())
            break;
        v = base * (v - e * lli(s[i - t.size()] - 'a')) + lli(s[i] - 'a');
        ((v %= mod) += mod) %= mod;
    }
    v = 0;
    rep(i, t.size())
    {
        v = v * base + t[i] - 'a';
        v %= mod;
    }
    e = 1;
    lli cnt = 0;
    rrep(j, t.size())
    {
        for (lli i = 0; i < 26; i++) {
            if (i == t[j] - 'a')
                continue;
            lli nx = ((v - lli(t[j] - 'a') * e + e * i) % mod + mod) % mod;
            cnt += st[nx];
        }
        (e *= base) %= mod;
    }
    cout << cnt << endl;
}

Submission Info

Submission Time
Task A - Invest Master
User uenoku
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1206 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
WA × 35
Set Name Test Cases
All 00_sample01.txt, 00_sample02.txt, 00_sample03.txt, 00_sample04.txt, 05_anti_greedy.txt, 10_rand_small00.txt, 10_rand_small01.txt, 10_rand_small02.txt, 10_rand_small03.txt, 10_rand_small04.txt, 10_rand_small05.txt, 10_rand_small06.txt, 10_rand_small07.txt, 10_rand_small08.txt, 10_rand_small09.txt, 20_rand_medium00.txt, 20_rand_medium01.txt, 20_rand_medium02.txt, 20_rand_medium03.txt, 20_rand_medium04.txt, 20_rand_medium05.txt, 20_rand_medium06.txt, 20_rand_medium07.txt, 20_rand_medium08.txt, 20_rand_medium09.txt, 30_rand_large00.txt, 30_rand_large01.txt, 30_rand_large02.txt, 30_rand_large03.txt, 30_rand_large04.txt, 30_rand_large05.txt, 30_rand_large06.txt, 30_rand_large07.txt, 30_rand_large08.txt, 30_rand_large09.txt
Case Name Status Exec Time Memory
00_sample01.txt WA 1 ms 256 KB
00_sample02.txt WA 1 ms 256 KB
00_sample03.txt WA 1 ms 256 KB
00_sample04.txt WA 1 ms 256 KB
05_anti_greedy.txt WA 1 ms 256 KB
10_rand_small00.txt WA 1 ms 256 KB
10_rand_small01.txt WA 1 ms 256 KB
10_rand_small02.txt WA 1 ms 256 KB
10_rand_small03.txt WA 1 ms 256 KB
10_rand_small04.txt WA 1 ms 256 KB
10_rand_small05.txt WA 1 ms 256 KB
10_rand_small06.txt WA 1 ms 256 KB
10_rand_small07.txt WA 1 ms 256 KB
10_rand_small08.txt WA 1 ms 256 KB
10_rand_small09.txt WA 1 ms 256 KB
20_rand_medium00.txt WA 1 ms 256 KB
20_rand_medium01.txt WA 1 ms 256 KB
20_rand_medium02.txt WA 1 ms 256 KB
20_rand_medium03.txt WA 1 ms 256 KB
20_rand_medium04.txt WA 1 ms 256 KB
20_rand_medium05.txt WA 1 ms 256 KB
20_rand_medium06.txt WA 1 ms 256 KB
20_rand_medium07.txt WA 1 ms 256 KB
20_rand_medium08.txt WA 1 ms 256 KB
20_rand_medium09.txt WA 1 ms 256 KB
30_rand_large00.txt WA 1 ms 256 KB
30_rand_large01.txt WA 1 ms 256 KB
30_rand_large02.txt WA 1 ms 256 KB
30_rand_large03.txt WA 1 ms 256 KB
30_rand_large04.txt WA 1 ms 256 KB
30_rand_large05.txt WA 1 ms 256 KB
30_rand_large06.txt WA 1 ms 256 KB
30_rand_large07.txt WA 1 ms 256 KB
30_rand_large08.txt WA 1 ms 256 KB
30_rand_large09.txt WA 1 ms 256 KB