# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
999008 |
2024-06-15T04:53:22 Z |
vjudge1 |
Trener (COCI20_trener) |
C++17 |
|
5 ms |
708 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int h = 569, mod = 1LL<<40, md = 1e9 + 7;
signed main()
{
int n,k;
cin>>n>>k;
map<int,int> ans;
int fin_ans=0,iv = (md+1)/2;
for (int a=1;a<=n;a++)
for (int b=0;b<k;b++)
{
string s;
cin>>s;
if (a==1)
{
ans[(int)s[0]]=1;
continue;
}
int hs[2]={},x=0;
for (int i=0;i<=1;i++)
{
for (int j=i;j<a-1+i;j++)
hs[i]=h*hs[i]+s[j],hs[i]%=mod;
if (ans.find(hs[i])!=ans.end())
x+=ans[hs[i]];
}
x%=md;
if (hs[0]==hs[1])
x=iv*x%md;
int sh=0;
for (int i=0;i<a;i++)
sh=h*sh+s[i],sh%=mod;
ans[sh]=x;
if (a==n)
fin_ans+=x,fin_ans%=md;
}
cout<<fin_ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |