QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#487377 | #6234. 动物园 | qycc | 100 ✓ | 94ms | 24960kb | C++14 | 1.0kb | 2024-07-22 20:50:07 | 2024-07-22 20:50:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
string a;
const long long M=1e9+7;//题目要求的取余
long long net[10000001],num[10000001],n;
long long f=1;//记录答案
void __next(string t){//模板
long long i=0,j=-1;
net[0]=-1;
while(i<t.size()){
if(j==-1||t[i]==t[j]){
i++;
j++;
net[i]=j;
num[i]=num[j]+1;//求num
}
else j=net[j];
}
return;
}
void __h(string t){
long long i=0,j=-1;
net[0]=-1;
while(i<t.size()){
if(j==-1||t[i]==t[j]){
i++;
j++;
while(j*2>i)j=net[j];//见思路
f=(f*(num[j]+1))%M;
}
else j=net[j];
}
return;
}
int main(){
cin>>n;
num[1]=1;
for(long long i=1;i<=n;i++){
cin>>a;
__next(a);
__h(a);
cout<<f<<"\n";
f=1;//注意为1,因为是乘法
//因为所有的都会被覆盖,所以数组不用初始化
}
return 0;
}
详细
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 0ms
memory: 5760kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaxpuvf abababababababababababababababababababababababdgcd abcbaabcbaabcbaabcbaabcbaabcbaabcbaabcbaabcbafmlqh abacababacababacababacababacababacababacababadjyxq aabaacaabaacaabaacaabaacaabaacaabaacaabaacaabjtaxw
output:
592345761 371390093 121623872 675691877 481106999
result:
ok 5 number(s): "592345761 371390093 121623872 675691877 481106999"
Test #2:
score: 10
Accepted
time: 1ms
memory: 5620kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaavtgynkaevpdhsdwswilx ababababababababababababababababababababababababababababababababababababababababababababababababa...
output:
469770619 76547694 933305750 902388437 803348921
result:
ok 5 number(s): "469770619 76547694 933305750 902388437 803348921"
Test #3:
score: 10
Accepted
time: 1ms
memory: 5688kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafcbwqryehhjfnlhglcnn ababababababababababababababababababababababababababababababababababababababababababababababababa...
output:
734885313 42387799 866611493 737798559 606697835
result:
ok 5 number(s): "734885313 42387799 866611493 737798559 606697835"
Test #4:
score: 10
Accepted
time: 0ms
memory: 5796kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
256900524 822524261 413461597 106784584 900200874
result:
ok 5 number(s): "256900524 822524261 413461597 106784584 900200874"
Test #5:
score: 10
Accepted
time: 1ms
memory: 5764kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
338653171 215976943 353365401 126668510 374446639
result:
ok 5 number(s): "338653171 215976943 353365401 126668510 374446639"
Test #6:
score: 10
Accepted
time: 7ms
memory: 10736kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
121054060 135829705 586084763 774583391 672914918
result:
ok 5 number(s): "121054060 135829705 586084763 774583391 672914918"
Test #7:
score: 10
Accepted
time: 10ms
memory: 9492kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
608896507 705745581 866882032 907283717 280168955
result:
ok 5 number(s): "608896507 705745581 866882032 907283717 280168955"
Test #8:
score: 10
Accepted
time: 48ms
memory: 15320kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
757739184 436599146 408735068 62286478 824797798
result:
ok 5 number(s): "757739184 436599146 408735068 62286478 824797798"
Test #9:
score: 10
Accepted
time: 94ms
memory: 24960kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
359993524 770772317 946742907 673664964 798002419
result:
ok 5 number(s): "359993524 770772317 946742907 673664964 798002419"
Test #10:
score: 10
Accepted
time: 90ms
memory: 24888kb
input:
5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
237665674 899763767 416501680 103496894 979807695
result:
ok 5 number(s): "237665674 899763767 416501680 103496894 979807695"
Extra Test:
score: 0
Extra Test Passed