QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#463656 | #7994. 勿蹖宠物 | C1942huangjiaxu | WA | 794ms | 8192kb | C++14 | 1.2kb | 2024-07-05 10:34:54 | 2024-07-05 10:34:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=605,P=1e9+7;
int n,L,m,ln[N],p[N][N],f[N][N],g[N][N],ans;
pair<int,int>pos[N];
char s[N][N];
inline void Add(int &x,int y){
if((x+=y)>=P)x-=P;
}
int main(){
scanf("%d%d",&n,&L);
for(int i=1;i<=n;++i){
scanf("%s",s[i]+1);
ln[i]=strlen(s[i]+1);
for(int j=1;j<=ln[i];++j)pos[++m]={i,j},p[i][j]=m;
}
f[0][0]=1;
for(int t=0;t<L/2;++t){
for(int i=0;i<=m;++i)for(int j=0;j<=m;++j)if(f[i][j]){
int w=f[i][j];
f[i][j]=0;
vector<pair<int,int> >vk,vl;
if(i)vk.emplace_back(pos[i].first,pos[i].second+1);
else for(int k=1;k<=n;++k)vk.emplace_back(k,1);
if(j)vl.emplace_back(pos[j].first,pos[j].second-1);
else for(int l=1;l<=n;++l)vl.emplace_back(l,ln[l]);
for(auto [ik,jk]:vk)for(auto [il,jl]:vl)if(s[ik][jk]==s[il][jl])
Add(g[jk==ln[ik]?0:p[ik][jk]][jl==1?0:p[il][jl]],w);
}
swap(f,g);
}
for(int i=0;i<=m;++i)for(int j=0;j<=m;++j)if(f[i][j]){
int a,b,c,d;
tie(a,b)=pos[i],tie(c,d)=pos[j];
if(!i){
if(!j){
if(!(L&1))Add(ans,f[i][j]);
}else if(d==(L&1)+1)Add(ans,f[i][j]);
}else{
if(!j){
if(b+(L&1)==ln[a])Add(ans,f[i][j]);
}else if(a==c&&b+1+(L&1)==d)Add(ans,f[i][j]);
}
}
printf("%d\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 7856kb
input:
7 9 cats eel eve evil lee olive stack
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 1ms
memory: 8076kb
input:
2 2 a aa
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 2ms
memory: 8192kb
input:
6 12 aa aab no on pets step
output:
43
result:
ok single line: '43'
Test #4:
score: 0
Accepted
time: 117ms
memory: 7864kb
input:
26 1000 a b c d e f g h i j k l m n o p q r s t u v w x y z
output:
710955506
result:
ok single line: '710955506'
Test #5:
score: 0
Accepted
time: 10ms
memory: 7340kb
input:
33 18 zrkodfkhhkfdokrzo ytcbwrgyygrwbcty makgiybggbyigkamc aptmvovgccgvovmtpa yydxdzhhhhzdxdyy iadqfexoxacojythvk iagcfiwlaalwifcgai rtfzhddzzddhzftrm vkreigbdyxfiuvyqid mbcgnvrvvrvngcbmc lywbtspuyyupstbwyl bmjxalsyyslaxjmb jrbminaooanimbrj wwrajerkkrejarww grocaiqccqiacorg efvibgurrugbivfec ilyzrft...
output:
9
result:
ok single line: '9'
Test #6:
score: 0
Accepted
time: 10ms
memory: 7132kb
input:
33 18 babbababbbbababbab abbabaabaabaababba aaabbbaabbaabbbaaa aaabaababbabaabaaa ababbaabbbbaabbaba baababbbbbbbbabaab aababbbaaaabbbabaa bbbbbabaaaababbbbb aabbbaaaaaaaabbbaa aabbbabaaaababbbaa bbabbaabaabaabbabb aababbabbbbabbabaa baaaaaabbbbaaaaaab aaabababaabababaaa bbaabbaaaaaabbaabb bbbababab...
output:
33
result:
ok single line: '33'
Test #7:
score: 0
Accepted
time: 9ms
memory: 8088kb
input:
33 18 babababaaaabababa abbbabbaaaabbabbba bbaaaabbaabbaaaabb baabbbbaaaabbbbaab abbbaababbabaabbb aaababbabbabbabaaa abbbbbbabbabbbbbba bbaabaaaaaaaabaabb aaaaabaaaaaabaaaaa abbbaabbbbbbaabbba abbbbaaaaaaaabbbba bbbbbbbbaabbbbbbbb baabaabbbbaabaab bbaababaaaababaabb baaabaabbbbaabaaab bbaaaabbbbbba...
output:
27
result:
ok single line: '27'
Test #8:
score: 0
Accepted
time: 6ms
memory: 7208kb
input:
33 18 bbbababaabababbb abaabaaabbaaabaaba aaabbbbbbaaaabbbab aaabbababbababbaaa abbaaabaabaaaaabbb abababaaaaaabababa bbabaaaaaaaababb bababbaaaaaabbaba aaaaababbbbabaaaa aaabaababbabaabaa abbbbbabbabbbbbaa abbbbbaabbaabbbbba abaaabbabaabbbabbb aabaabbbaabbbaabaa aaababbbbbabababaa abaaabbaabbaaabab...
output:
8
result:
ok single line: '8'
Test #9:
score: -100
Wrong Answer
time: 794ms
memory: 7348kb
input:
199 999 lbl buei ieub uw wu impv vpmi yrek kery cw wc hjs sjh bct tcb up pu wh hw ftn ntf iv vi ejpj jpje qjgh hgjq kvny ynvk xo ox pr rp sdh hds go og qw wq bgt tgb czwk kwzc coqr rqoc af fa ms sm gs sg hnz znh rugm mgur lak kal xlv vlx na an fdoe eodf oixg gxio mb bm bjt tjb bto otb oxq qxo tg gt ...
output:
389143805
result:
wrong answer 1st lines differ - expected: '810133722', found: '389143805'