#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,i,j,k,l,r,x,y,z,w,s,t,a[12][110][110],dp[110][110][110],m;
map<ll,ll> mp;
const ll mod=998244353;
char c[110000];
ll tr(char c)
{
if(c>='a')
return c-'a'+1;
if(c>='A')
return c-'A'+1+26;
return c-'0'+1+26+26;
}
ll palin()
{
ll i;
for(i=0;i<m;i++)
{
if(c[i]!=c[m-1-i])
return 0;
}
return 1;
}
ll f(ll x)
{
ll i,t=0,j,k,l;
for(i=1;i<=62;i++)
{
for(j=1;j<=62;j++)
{
for(k=1;k<=62;k++)
{
dp[i][j][k]=0;
for(l=1;l<=62;l++)
{
dp[i][j][k]+=a[x][i][l]*a[x][j][l]*a[x][k][l];
dp[i][j][k]%=mod;
}
}
}
}
for(i=1;i<=62;i++)
{
for(j=1;j<=62;j++)
{
for(k=1;k<=62;k++)
{
for(l=1;l<=62;l++)
{
t=(t+dp[i][j][k]*dp[i][j][l]%mod*dp[i][k][l]%mod*dp[j][k][l]%mod)%mod;
}
}
}
}
return t;
}
int main()
{
scanf("%lld",&n);
for(i=1;i<=n;i++)
{
scanf("\n%s",c);
m=strlen(c);
x=tr(c[0]);
y=tr(c[m-1]);
z=0;
for(j=0;j<m;j++)
{
z=z*63+tr(c[j]);
}
if(mp[z]==1)
continue;
z=0;
for(j=m-1;j>=0;j--)
{
z=z*63+tr(c[j]);
}
if(mp[z]==1)
continue;
mp[z]=1;
if(palin())
{
a[m][x][y]++;
}
else
{
a[m][x][y]++;
a[m][y][x]++;
}
}
//printf("!");
for(i=3;i<=10;i++)
{
s=(s+f(i))%mod;
}
printf("%lld",s);
}
Compilation message
cubeword.cpp: In function 'int main()':
cubeword.cpp:73:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
73 | if(mp[z]==1)
| ^~
cubeword.cpp:75:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
75 | z=0;
| ^
cubeword.cpp:61:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
61 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
cubeword.cpp:64:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
64 | scanf("\n%s",c);
| ~~~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1130 ms |
18412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1130 ms |
18412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1130 ms |
18412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1130 ms |
18412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |