QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#244465#4484. AC/DCucup-team203#WA 5724ms241160kbC++202.2kb2023-11-09 09:30:092023-11-09 09:30:10

Judging History

你现在查看的是最新测评结果

  • [2023-11-09 09:30:10]
  • 评测
  • 测评结果:WA
  • 用时:5724ms
  • 内存:241160kb
  • [2023-11-09 09:30:09]
  • 提交

answer

#include <bits/stdc++.h>
using i64 = long long;
using namespace std;
const int N = 2e5 + 5;
// const int B = 400;
// const int M = 4e6 + 5;
const int base = 15171;
const int mod = 998244353;
// const i64 mod = (i64)1e18 + 7;
// const double pi = acos(-1);

int p[N], h[N];
int opt, m;
string s, c;
int get(int l, int r)
{
    return (h[r] - (i64)h[l - 1] * p[r - l + 1] % mod + mod) % mod;
}
int cal(string &s)
{
    int res = 0;
    for (char c : s)
        res = ((i64)res * base % mod + (c - 'a' + 1)) % mod;
    return res;
}
void solve()
{
    cin >> s >> m;
    int n = s.length(), l = 1, r = n;
    for (int i = 0; i < n; i++)
        h[i + 1] = ((i64)h[i] * base % mod + (s[i] - 'a' + 1)) % mod;
    int ans = 0;
    map<int, map<int, int>> cnt;
    while (m--)
    {
        cin >> opt;
        if (opt == 1)
        {
            cin >> c;
            c[0] = char(((c[0] - 'a') ^ ans) % 26 + 'a');
            r++;
            h[r] = ((i64)h[r - 1] * base % mod + (c[0] - 'a' + 1)) % mod;
            for (auto &[len, t] : cnt)
            {
                int tmp = get(r - len + 1, r);
                t[tmp]++;
            }
        }
        else if (opt == 2)
        {
            for (auto &[len, t] : cnt)
            {
                int tmp = get(l, l + len - 1);
                if (!--t[tmp])
                    t.erase(tmp);
            }
            l++;
        }
        else
        {
            cin >> c;
            for (char &d : c)
                d = char(((d - 'a') ^ ans) % 26 + 'a');
            ans = 0;
            int len = c.length(), tmp = cal(c);
            if (!cnt.count(len))
            {
                for (int j = l + len - 1; j <= r; j++)
                    cnt[len][get(j - len + 1, j)]++;
            }
            if (cnt[len].count(tmp))
                ans = cnt[len][tmp];
            cout << ans << '\n';
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    p[0] = 1;
    for (int i = 1; i < N; i++)
        p[i] = (i64)p[i - 1] * base % mod;
    int t = 1;
    cin >> t;
    // cout << fixed << setprecision(10);
    while (t--)
        solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 5724ms
memory: 241160kb

input:

5
bdcdeabadbeddbecdcecabcdebaccaedbeabaccbdbeebebeebdddcaceedeccabddddadbddbcdaeaceabcceeebcedddeebeaeabbdbcecbdcbedbbebeccecadbabbedddcecacddceaededdbaeecccacaaddcddacacbbacaeceedbdddaabaadadddbdbebbaecbebcbcebaedcaaacbeecedcacbddedabaacbbcaaacdadbaecdeabbdbbdebbbecdcbcbedbaebcdaaebacddeddccbcacbbe...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 35514th lines differ - expected: '0', found: '1'