QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#631994#7876. Cyclic Substringsfrankly6WA 0ms3572kbC++171012b2024-10-12 11:21:072024-10-12 11:21:07

Judging History

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

  • [2024-10-12 11:21:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3572kb
  • [2024-10-12 11:21:07]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int MX=3000300;
const int P=998244353;

int N, cur, siz=1;
string s;
struct node{int ch[10],f,num,len,c;}t[2*MX];
int gf(int id, int p)
{
    while(s[p-t[id].len-1]!=s[p]) id=t[id].f;
    return id;
}
int main()
{
    freopen("testdata.in","r",stdin);
    cin >> N >> s; s=" "+s+s;
    t[0].f=1; t[1].len=-1;
    for(int i=1;i<=2*N;i++)
    {
        int p=gf(cur,i);
        if(!t[p].ch[s[i]-'0'])
        {
            t[++siz].f=t[gf(t[p].f,i)].ch[s[i]-'0'];
            int &v=t[p].ch[s[i]-'0']=siz;
            t[v].len=t[p].len+2;
            t[v].num=t[t[v].f].num+1;
        }
        cur=t[p].ch[s[i]-'0'];
        if(i>N) t[cur].c++;
    }
    ll ans=0;
    for(int i=siz;i>=0;i--) 
    {
        t[t[i].f].c+=t[i].c;
        if(t[i].len<=N) ans=(ans+1ll*t[i].c*t[i].c%P*t[i].len%P)%P;
    }
    cout << ans << '\n';
    return (0-0);
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3572kb

input:

5
01010

output:

0

result:

wrong answer 1st numbers differ - expected: '39', found: '0'