#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;
}
}
}
}
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 |
Correct |
978 ms |
18412 KB |
Output is correct |
2 |
Correct |
968 ms |
19280 KB |
Output is correct |
3 |
Correct |
988 ms |
19096 KB |
Output is correct |
4 |
Correct |
978 ms |
19084 KB |
Output is correct |
5 |
Correct |
979 ms |
19280 KB |
Output is correct |
6 |
Correct |
980 ms |
19096 KB |
Output is correct |
7 |
Correct |
985 ms |
19104 KB |
Output is correct |
8 |
Correct |
1028 ms |
18948 KB |
Output is correct |
9 |
Correct |
1002 ms |
19284 KB |
Output is correct |
10 |
Correct |
973 ms |
19312 KB |
Output is correct |
11 |
Correct |
970 ms |
19152 KB |
Output is correct |
12 |
Correct |
972 ms |
19332 KB |
Output is correct |
13 |
Correct |
970 ms |
19104 KB |
Output is correct |
14 |
Correct |
985 ms |
19092 KB |
Output is correct |
15 |
Correct |
975 ms |
19104 KB |
Output is correct |
16 |
Correct |
994 ms |
19340 KB |
Output is correct |
17 |
Correct |
972 ms |
19280 KB |
Output is correct |
18 |
Correct |
983 ms |
19084 KB |
Output is correct |
19 |
Correct |
999 ms |
19084 KB |
Output is correct |
20 |
Correct |
974 ms |
19280 KB |
Output is correct |
21 |
Correct |
976 ms |
19084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
978 ms |
18412 KB |
Output is correct |
2 |
Correct |
968 ms |
19280 KB |
Output is correct |
3 |
Correct |
988 ms |
19096 KB |
Output is correct |
4 |
Correct |
978 ms |
19084 KB |
Output is correct |
5 |
Correct |
979 ms |
19280 KB |
Output is correct |
6 |
Correct |
980 ms |
19096 KB |
Output is correct |
7 |
Correct |
985 ms |
19104 KB |
Output is correct |
8 |
Correct |
1028 ms |
18948 KB |
Output is correct |
9 |
Correct |
1002 ms |
19284 KB |
Output is correct |
10 |
Correct |
973 ms |
19312 KB |
Output is correct |
11 |
Correct |
970 ms |
19152 KB |
Output is correct |
12 |
Correct |
972 ms |
19332 KB |
Output is correct |
13 |
Correct |
970 ms |
19104 KB |
Output is correct |
14 |
Correct |
985 ms |
19092 KB |
Output is correct |
15 |
Correct |
975 ms |
19104 KB |
Output is correct |
16 |
Correct |
994 ms |
19340 KB |
Output is correct |
17 |
Correct |
972 ms |
19280 KB |
Output is correct |
18 |
Correct |
983 ms |
19084 KB |
Output is correct |
19 |
Correct |
999 ms |
19084 KB |
Output is correct |
20 |
Correct |
974 ms |
19280 KB |
Output is correct |
21 |
Correct |
976 ms |
19084 KB |
Output is correct |
22 |
Correct |
1020 ms |
19540 KB |
Output is correct |
23 |
Correct |
979 ms |
19604 KB |
Output is correct |
24 |
Correct |
981 ms |
19600 KB |
Output is correct |
25 |
Correct |
982 ms |
19608 KB |
Output is correct |
26 |
Correct |
997 ms |
19596 KB |
Output is correct |
27 |
Correct |
979 ms |
19604 KB |
Output is correct |
28 |
Correct |
983 ms |
19604 KB |
Output is correct |
29 |
Correct |
974 ms |
19792 KB |
Output is correct |
30 |
Correct |
981 ms |
19600 KB |
Output is correct |
31 |
Correct |
971 ms |
19608 KB |
Output is correct |
32 |
Correct |
978 ms |
19596 KB |
Output is correct |
33 |
Correct |
983 ms |
19600 KB |
Output is correct |
34 |
Correct |
990 ms |
19728 KB |
Output is correct |
35 |
Correct |
991 ms |
19600 KB |
Output is correct |
36 |
Correct |
988 ms |
19612 KB |
Output is correct |
37 |
Correct |
979 ms |
19844 KB |
Output is correct |
38 |
Correct |
977 ms |
19608 KB |
Output is correct |
39 |
Correct |
972 ms |
19608 KB |
Output is correct |
40 |
Correct |
997 ms |
19604 KB |
Output is correct |
41 |
Correct |
974 ms |
19604 KB |
Output is correct |
42 |
Correct |
983 ms |
19616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
978 ms |
18412 KB |
Output is correct |
2 |
Correct |
968 ms |
19280 KB |
Output is correct |
3 |
Correct |
988 ms |
19096 KB |
Output is correct |
4 |
Correct |
978 ms |
19084 KB |
Output is correct |
5 |
Correct |
979 ms |
19280 KB |
Output is correct |
6 |
Correct |
980 ms |
19096 KB |
Output is correct |
7 |
Correct |
985 ms |
19104 KB |
Output is correct |
8 |
Correct |
1028 ms |
18948 KB |
Output is correct |
9 |
Correct |
1002 ms |
19284 KB |
Output is correct |
10 |
Correct |
973 ms |
19312 KB |
Output is correct |
11 |
Correct |
970 ms |
19152 KB |
Output is correct |
12 |
Correct |
972 ms |
19332 KB |
Output is correct |
13 |
Correct |
970 ms |
19104 KB |
Output is correct |
14 |
Correct |
985 ms |
19092 KB |
Output is correct |
15 |
Correct |
975 ms |
19104 KB |
Output is correct |
16 |
Correct |
994 ms |
19340 KB |
Output is correct |
17 |
Correct |
972 ms |
19280 KB |
Output is correct |
18 |
Correct |
983 ms |
19084 KB |
Output is correct |
19 |
Correct |
999 ms |
19084 KB |
Output is correct |
20 |
Correct |
974 ms |
19280 KB |
Output is correct |
21 |
Correct |
976 ms |
19084 KB |
Output is correct |
22 |
Correct |
1020 ms |
19540 KB |
Output is correct |
23 |
Correct |
979 ms |
19604 KB |
Output is correct |
24 |
Correct |
981 ms |
19600 KB |
Output is correct |
25 |
Correct |
982 ms |
19608 KB |
Output is correct |
26 |
Correct |
997 ms |
19596 KB |
Output is correct |
27 |
Correct |
979 ms |
19604 KB |
Output is correct |
28 |
Correct |
983 ms |
19604 KB |
Output is correct |
29 |
Correct |
974 ms |
19792 KB |
Output is correct |
30 |
Correct |
981 ms |
19600 KB |
Output is correct |
31 |
Correct |
971 ms |
19608 KB |
Output is correct |
32 |
Correct |
978 ms |
19596 KB |
Output is correct |
33 |
Correct |
983 ms |
19600 KB |
Output is correct |
34 |
Correct |
990 ms |
19728 KB |
Output is correct |
35 |
Correct |
991 ms |
19600 KB |
Output is correct |
36 |
Correct |
988 ms |
19612 KB |
Output is correct |
37 |
Correct |
979 ms |
19844 KB |
Output is correct |
38 |
Correct |
977 ms |
19608 KB |
Output is correct |
39 |
Correct |
972 ms |
19608 KB |
Output is correct |
40 |
Correct |
997 ms |
19604 KB |
Output is correct |
41 |
Correct |
974 ms |
19604 KB |
Output is correct |
42 |
Correct |
983 ms |
19616 KB |
Output is correct |
43 |
Correct |
977 ms |
20052 KB |
Output is correct |
44 |
Correct |
983 ms |
20108 KB |
Output is correct |
45 |
Correct |
985 ms |
20048 KB |
Output is correct |
46 |
Correct |
978 ms |
19884 KB |
Output is correct |
47 |
Correct |
985 ms |
19880 KB |
Output is correct |
48 |
Correct |
992 ms |
20236 KB |
Output is correct |
49 |
Correct |
987 ms |
19888 KB |
Output is correct |
50 |
Correct |
1002 ms |
19792 KB |
Output is correct |
51 |
Correct |
992 ms |
20116 KB |
Output is correct |
52 |
Correct |
986 ms |
19880 KB |
Output is correct |
53 |
Correct |
1000 ms |
19888 KB |
Output is correct |
54 |
Correct |
981 ms |
20200 KB |
Output is correct |
55 |
Correct |
1000 ms |
19892 KB |
Output is correct |
56 |
Correct |
980 ms |
19892 KB |
Output is correct |
57 |
Correct |
1004 ms |
19872 KB |
Output is correct |
58 |
Correct |
1056 ms |
19892 KB |
Output is correct |
59 |
Correct |
1065 ms |
19888 KB |
Output is correct |
60 |
Correct |
1000 ms |
20128 KB |
Output is correct |
61 |
Correct |
1008 ms |
19780 KB |
Output is correct |
62 |
Correct |
977 ms |
19876 KB |
Output is correct |
63 |
Correct |
1002 ms |
19888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
978 ms |
18412 KB |
Output is correct |
2 |
Correct |
968 ms |
19280 KB |
Output is correct |
3 |
Correct |
988 ms |
19096 KB |
Output is correct |
4 |
Correct |
978 ms |
19084 KB |
Output is correct |
5 |
Correct |
979 ms |
19280 KB |
Output is correct |
6 |
Correct |
980 ms |
19096 KB |
Output is correct |
7 |
Correct |
985 ms |
19104 KB |
Output is correct |
8 |
Correct |
1028 ms |
18948 KB |
Output is correct |
9 |
Correct |
1002 ms |
19284 KB |
Output is correct |
10 |
Correct |
973 ms |
19312 KB |
Output is correct |
11 |
Correct |
970 ms |
19152 KB |
Output is correct |
12 |
Correct |
972 ms |
19332 KB |
Output is correct |
13 |
Correct |
970 ms |
19104 KB |
Output is correct |
14 |
Correct |
985 ms |
19092 KB |
Output is correct |
15 |
Correct |
975 ms |
19104 KB |
Output is correct |
16 |
Correct |
994 ms |
19340 KB |
Output is correct |
17 |
Correct |
972 ms |
19280 KB |
Output is correct |
18 |
Correct |
983 ms |
19084 KB |
Output is correct |
19 |
Correct |
999 ms |
19084 KB |
Output is correct |
20 |
Correct |
974 ms |
19280 KB |
Output is correct |
21 |
Correct |
976 ms |
19084 KB |
Output is correct |
22 |
Correct |
1020 ms |
19540 KB |
Output is correct |
23 |
Correct |
979 ms |
19604 KB |
Output is correct |
24 |
Correct |
981 ms |
19600 KB |
Output is correct |
25 |
Correct |
982 ms |
19608 KB |
Output is correct |
26 |
Correct |
997 ms |
19596 KB |
Output is correct |
27 |
Correct |
979 ms |
19604 KB |
Output is correct |
28 |
Correct |
983 ms |
19604 KB |
Output is correct |
29 |
Correct |
974 ms |
19792 KB |
Output is correct |
30 |
Correct |
981 ms |
19600 KB |
Output is correct |
31 |
Correct |
971 ms |
19608 KB |
Output is correct |
32 |
Correct |
978 ms |
19596 KB |
Output is correct |
33 |
Correct |
983 ms |
19600 KB |
Output is correct |
34 |
Correct |
990 ms |
19728 KB |
Output is correct |
35 |
Correct |
991 ms |
19600 KB |
Output is correct |
36 |
Correct |
988 ms |
19612 KB |
Output is correct |
37 |
Correct |
979 ms |
19844 KB |
Output is correct |
38 |
Correct |
977 ms |
19608 KB |
Output is correct |
39 |
Correct |
972 ms |
19608 KB |
Output is correct |
40 |
Correct |
997 ms |
19604 KB |
Output is correct |
41 |
Correct |
974 ms |
19604 KB |
Output is correct |
42 |
Correct |
983 ms |
19616 KB |
Output is correct |
43 |
Correct |
977 ms |
20052 KB |
Output is correct |
44 |
Correct |
983 ms |
20108 KB |
Output is correct |
45 |
Correct |
985 ms |
20048 KB |
Output is correct |
46 |
Correct |
978 ms |
19884 KB |
Output is correct |
47 |
Correct |
985 ms |
19880 KB |
Output is correct |
48 |
Correct |
992 ms |
20236 KB |
Output is correct |
49 |
Correct |
987 ms |
19888 KB |
Output is correct |
50 |
Correct |
1002 ms |
19792 KB |
Output is correct |
51 |
Correct |
992 ms |
20116 KB |
Output is correct |
52 |
Correct |
986 ms |
19880 KB |
Output is correct |
53 |
Correct |
1000 ms |
19888 KB |
Output is correct |
54 |
Correct |
981 ms |
20200 KB |
Output is correct |
55 |
Correct |
1000 ms |
19892 KB |
Output is correct |
56 |
Correct |
980 ms |
19892 KB |
Output is correct |
57 |
Correct |
1004 ms |
19872 KB |
Output is correct |
58 |
Correct |
1056 ms |
19892 KB |
Output is correct |
59 |
Correct |
1065 ms |
19888 KB |
Output is correct |
60 |
Correct |
1000 ms |
20128 KB |
Output is correct |
61 |
Correct |
1008 ms |
19780 KB |
Output is correct |
62 |
Correct |
977 ms |
19876 KB |
Output is correct |
63 |
Correct |
1002 ms |
19888 KB |
Output is correct |
64 |
Correct |
989 ms |
20244 KB |
Output is correct |
65 |
Correct |
987 ms |
20236 KB |
Output is correct |
66 |
Correct |
1000 ms |
20240 KB |
Output is correct |
67 |
Correct |
983 ms |
20304 KB |
Output is correct |
68 |
Correct |
1027 ms |
20240 KB |
Output is correct |
69 |
Correct |
1008 ms |
20232 KB |
Output is correct |
70 |
Correct |
992 ms |
20240 KB |
Output is correct |
71 |
Correct |
1008 ms |
20308 KB |
Output is correct |
72 |
Correct |
1012 ms |
20228 KB |
Output is correct |
73 |
Correct |
977 ms |
20388 KB |
Output is correct |
74 |
Correct |
1000 ms |
20292 KB |
Output is correct |
75 |
Correct |
1002 ms |
20236 KB |
Output is correct |
76 |
Correct |
1006 ms |
20244 KB |
Output is correct |
77 |
Correct |
998 ms |
20356 KB |
Output is correct |
78 |
Correct |
982 ms |
20252 KB |
Output is correct |
79 |
Correct |
1004 ms |
20240 KB |
Output is correct |
80 |
Correct |
982 ms |
20236 KB |
Output is correct |
81 |
Correct |
976 ms |
20328 KB |
Output is correct |
82 |
Correct |
985 ms |
20452 KB |
Output is correct |
83 |
Correct |
987 ms |
20248 KB |
Output is correct |
84 |
Correct |
990 ms |
20236 KB |
Output is correct |