#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
int n,m,G[11][128][128],pos[128],f[128][128][128];
string s[200010];
char g[128];
bool vis[128];
long long ans;
int main()
{
//freopen("cubeword.in","r",stdin);
//freopen("cubeword.out","w",stdout);
scanf("%d",&n);
int x,y,z,i,j;
for(i=1;i<=n;i++) {
cin>>s[i];s[i+n]=s[i];
reverse(s[i+n].begin(),s[i+n].end());
for(j=0;j<s[i].size();j++) vis[s[i][j]]=1;
}
n*=2;
sort(s+1,s+n+1);
n=unique(s+1,s+n+1)-s-1;
for(int i=0;i<128;i++) if(vis[i]) g[++m]=i,pos[i]=m;
for(int i=1;i<=n;i++) G[s[i].size()][pos[s[i][0]]][pos[s[i][s[i].size()-1]]]++;
for(int len=3;len<=10;len++) {
// memset(f,0,sizeof(f));
for(x=1;x<=m;x++)
for(y=1;y<=m;y++)
for(z=1;z<=m;z++) {
f[x][y][z]=0;
for(i=1;i<=m;i++)
f[x][y][z]=(f[x][y][z]+1ll*G[len][i][x]*G[len][i][y]%mod*G[len][i][z]%mod)%mod;
}
for(i=1;i<=m;i++)
for(x=1;x<=m;x++)
for(y=1;y<=m;y++)
for(z=1;z<=m;z++)
ans=(ans+1ll*f[i][x][y]*f[i][x][z]%mod*f[i][y][z]%mod*f[x][y][z]%mod)%mod;
}
printf("%lld",ans);
return 0;
}
Compilation message
cubeword.cpp: In function 'int main()':
cubeword.cpp:18:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(j=0;j<s[i].size();j++) vis[s[i][j]]=1;
| ~^~~~~~~~~~~~
cubeword.cpp:18:41: warning: array subscript has type 'char' [-Wchar-subscripts]
18 | for(j=0;j<s[i].size();j++) vis[s[i][j]]=1;
| ^
cubeword.cpp:24:50: warning: array subscript has type 'char' [-Wchar-subscripts]
24 | for(int i=1;i<=n;i++) G[s[i].size()][pos[s[i][0]]][pos[s[i][s[i].size()-1]]]++;
| ^
cubeword.cpp:24:76: warning: array subscript has type 'char' [-Wchar-subscripts]
24 | for(int i=1;i<=n;i++) G[s[i].size()][pos[s[i][0]]][pos[s[i][s[i].size()-1]]]++;
| ^
cubeword.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
10828 KB |
Output is correct |
2 |
Correct |
72 ms |
10836 KB |
Output is correct |
3 |
Correct |
72 ms |
10832 KB |
Output is correct |
4 |
Correct |
71 ms |
10856 KB |
Output is correct |
5 |
Correct |
71 ms |
10832 KB |
Output is correct |
6 |
Correct |
72 ms |
10836 KB |
Output is correct |
7 |
Correct |
72 ms |
11092 KB |
Output is correct |
8 |
Correct |
71 ms |
10844 KB |
Output is correct |
9 |
Correct |
71 ms |
10844 KB |
Output is correct |
10 |
Correct |
75 ms |
10836 KB |
Output is correct |
11 |
Correct |
71 ms |
10848 KB |
Output is correct |
12 |
Correct |
71 ms |
10832 KB |
Output is correct |
13 |
Correct |
72 ms |
10832 KB |
Output is correct |
14 |
Correct |
72 ms |
10836 KB |
Output is correct |
15 |
Correct |
76 ms |
10832 KB |
Output is correct |
16 |
Correct |
71 ms |
10832 KB |
Output is correct |
17 |
Correct |
71 ms |
10848 KB |
Output is correct |
18 |
Correct |
75 ms |
10832 KB |
Output is correct |
19 |
Correct |
70 ms |
10836 KB |
Output is correct |
20 |
Correct |
71 ms |
10832 KB |
Output is correct |
21 |
Correct |
83 ms |
10852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
10828 KB |
Output is correct |
2 |
Correct |
72 ms |
10836 KB |
Output is correct |
3 |
Correct |
72 ms |
10832 KB |
Output is correct |
4 |
Correct |
71 ms |
10856 KB |
Output is correct |
5 |
Correct |
71 ms |
10832 KB |
Output is correct |
6 |
Correct |
72 ms |
10836 KB |
Output is correct |
7 |
Correct |
72 ms |
11092 KB |
Output is correct |
8 |
Correct |
71 ms |
10844 KB |
Output is correct |
9 |
Correct |
71 ms |
10844 KB |
Output is correct |
10 |
Correct |
75 ms |
10836 KB |
Output is correct |
11 |
Correct |
71 ms |
10848 KB |
Output is correct |
12 |
Correct |
71 ms |
10832 KB |
Output is correct |
13 |
Correct |
72 ms |
10832 KB |
Output is correct |
14 |
Correct |
72 ms |
10836 KB |
Output is correct |
15 |
Correct |
76 ms |
10832 KB |
Output is correct |
16 |
Correct |
71 ms |
10832 KB |
Output is correct |
17 |
Correct |
71 ms |
10848 KB |
Output is correct |
18 |
Correct |
75 ms |
10832 KB |
Output is correct |
19 |
Correct |
70 ms |
10836 KB |
Output is correct |
20 |
Correct |
71 ms |
10832 KB |
Output is correct |
21 |
Correct |
83 ms |
10852 KB |
Output is correct |
22 |
Correct |
72 ms |
10836 KB |
Output is correct |
23 |
Correct |
71 ms |
10836 KB |
Output is correct |
24 |
Correct |
72 ms |
10832 KB |
Output is correct |
25 |
Correct |
74 ms |
10852 KB |
Output is correct |
26 |
Correct |
72 ms |
10852 KB |
Output is correct |
27 |
Correct |
74 ms |
10848 KB |
Output is correct |
28 |
Correct |
73 ms |
10832 KB |
Output is correct |
29 |
Correct |
73 ms |
10852 KB |
Output is correct |
30 |
Correct |
71 ms |
10836 KB |
Output is correct |
31 |
Correct |
74 ms |
10832 KB |
Output is correct |
32 |
Correct |
72 ms |
10944 KB |
Output is correct |
33 |
Correct |
74 ms |
10848 KB |
Output is correct |
34 |
Correct |
73 ms |
10836 KB |
Output is correct |
35 |
Correct |
74 ms |
10836 KB |
Output is correct |
36 |
Correct |
73 ms |
10832 KB |
Output is correct |
37 |
Correct |
72 ms |
10832 KB |
Output is correct |
38 |
Correct |
72 ms |
10832 KB |
Output is correct |
39 |
Correct |
71 ms |
11092 KB |
Output is correct |
40 |
Correct |
75 ms |
10832 KB |
Output is correct |
41 |
Correct |
85 ms |
10832 KB |
Output is correct |
42 |
Correct |
72 ms |
10836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
10828 KB |
Output is correct |
2 |
Correct |
72 ms |
10836 KB |
Output is correct |
3 |
Correct |
72 ms |
10832 KB |
Output is correct |
4 |
Correct |
71 ms |
10856 KB |
Output is correct |
5 |
Correct |
71 ms |
10832 KB |
Output is correct |
6 |
Correct |
72 ms |
10836 KB |
Output is correct |
7 |
Correct |
72 ms |
11092 KB |
Output is correct |
8 |
Correct |
71 ms |
10844 KB |
Output is correct |
9 |
Correct |
71 ms |
10844 KB |
Output is correct |
10 |
Correct |
75 ms |
10836 KB |
Output is correct |
11 |
Correct |
71 ms |
10848 KB |
Output is correct |
12 |
Correct |
71 ms |
10832 KB |
Output is correct |
13 |
Correct |
72 ms |
10832 KB |
Output is correct |
14 |
Correct |
72 ms |
10836 KB |
Output is correct |
15 |
Correct |
76 ms |
10832 KB |
Output is correct |
16 |
Correct |
71 ms |
10832 KB |
Output is correct |
17 |
Correct |
71 ms |
10848 KB |
Output is correct |
18 |
Correct |
75 ms |
10832 KB |
Output is correct |
19 |
Correct |
70 ms |
10836 KB |
Output is correct |
20 |
Correct |
71 ms |
10832 KB |
Output is correct |
21 |
Correct |
83 ms |
10852 KB |
Output is correct |
22 |
Correct |
72 ms |
10836 KB |
Output is correct |
23 |
Correct |
71 ms |
10836 KB |
Output is correct |
24 |
Correct |
72 ms |
10832 KB |
Output is correct |
25 |
Correct |
74 ms |
10852 KB |
Output is correct |
26 |
Correct |
72 ms |
10852 KB |
Output is correct |
27 |
Correct |
74 ms |
10848 KB |
Output is correct |
28 |
Correct |
73 ms |
10832 KB |
Output is correct |
29 |
Correct |
73 ms |
10852 KB |
Output is correct |
30 |
Correct |
71 ms |
10836 KB |
Output is correct |
31 |
Correct |
74 ms |
10832 KB |
Output is correct |
32 |
Correct |
72 ms |
10944 KB |
Output is correct |
33 |
Correct |
74 ms |
10848 KB |
Output is correct |
34 |
Correct |
73 ms |
10836 KB |
Output is correct |
35 |
Correct |
74 ms |
10836 KB |
Output is correct |
36 |
Correct |
73 ms |
10832 KB |
Output is correct |
37 |
Correct |
72 ms |
10832 KB |
Output is correct |
38 |
Correct |
72 ms |
10832 KB |
Output is correct |
39 |
Correct |
71 ms |
11092 KB |
Output is correct |
40 |
Correct |
75 ms |
10832 KB |
Output is correct |
41 |
Correct |
85 ms |
10832 KB |
Output is correct |
42 |
Correct |
72 ms |
10836 KB |
Output is correct |
43 |
Correct |
155 ms |
10836 KB |
Output is correct |
44 |
Correct |
153 ms |
11600 KB |
Output is correct |
45 |
Correct |
157 ms |
11752 KB |
Output is correct |
46 |
Correct |
155 ms |
11744 KB |
Output is correct |
47 |
Correct |
154 ms |
11576 KB |
Output is correct |
48 |
Correct |
155 ms |
11748 KB |
Output is correct |
49 |
Correct |
159 ms |
11748 KB |
Output is correct |
50 |
Correct |
157 ms |
11580 KB |
Output is correct |
51 |
Correct |
153 ms |
11604 KB |
Output is correct |
52 |
Correct |
157 ms |
11856 KB |
Output is correct |
53 |
Correct |
160 ms |
11580 KB |
Output is correct |
54 |
Correct |
154 ms |
11604 KB |
Output is correct |
55 |
Correct |
154 ms |
11604 KB |
Output is correct |
56 |
Correct |
153 ms |
11600 KB |
Output is correct |
57 |
Correct |
156 ms |
11572 KB |
Output is correct |
58 |
Correct |
155 ms |
11604 KB |
Output is correct |
59 |
Correct |
159 ms |
11744 KB |
Output is correct |
60 |
Correct |
176 ms |
11728 KB |
Output is correct |
61 |
Correct |
153 ms |
11604 KB |
Output is correct |
62 |
Correct |
154 ms |
11604 KB |
Output is correct |
63 |
Correct |
152 ms |
11604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
10828 KB |
Output is correct |
2 |
Correct |
72 ms |
10836 KB |
Output is correct |
3 |
Correct |
72 ms |
10832 KB |
Output is correct |
4 |
Correct |
71 ms |
10856 KB |
Output is correct |
5 |
Correct |
71 ms |
10832 KB |
Output is correct |
6 |
Correct |
72 ms |
10836 KB |
Output is correct |
7 |
Correct |
72 ms |
11092 KB |
Output is correct |
8 |
Correct |
71 ms |
10844 KB |
Output is correct |
9 |
Correct |
71 ms |
10844 KB |
Output is correct |
10 |
Correct |
75 ms |
10836 KB |
Output is correct |
11 |
Correct |
71 ms |
10848 KB |
Output is correct |
12 |
Correct |
71 ms |
10832 KB |
Output is correct |
13 |
Correct |
72 ms |
10832 KB |
Output is correct |
14 |
Correct |
72 ms |
10836 KB |
Output is correct |
15 |
Correct |
76 ms |
10832 KB |
Output is correct |
16 |
Correct |
71 ms |
10832 KB |
Output is correct |
17 |
Correct |
71 ms |
10848 KB |
Output is correct |
18 |
Correct |
75 ms |
10832 KB |
Output is correct |
19 |
Correct |
70 ms |
10836 KB |
Output is correct |
20 |
Correct |
71 ms |
10832 KB |
Output is correct |
21 |
Correct |
83 ms |
10852 KB |
Output is correct |
22 |
Correct |
72 ms |
10836 KB |
Output is correct |
23 |
Correct |
71 ms |
10836 KB |
Output is correct |
24 |
Correct |
72 ms |
10832 KB |
Output is correct |
25 |
Correct |
74 ms |
10852 KB |
Output is correct |
26 |
Correct |
72 ms |
10852 KB |
Output is correct |
27 |
Correct |
74 ms |
10848 KB |
Output is correct |
28 |
Correct |
73 ms |
10832 KB |
Output is correct |
29 |
Correct |
73 ms |
10852 KB |
Output is correct |
30 |
Correct |
71 ms |
10836 KB |
Output is correct |
31 |
Correct |
74 ms |
10832 KB |
Output is correct |
32 |
Correct |
72 ms |
10944 KB |
Output is correct |
33 |
Correct |
74 ms |
10848 KB |
Output is correct |
34 |
Correct |
73 ms |
10836 KB |
Output is correct |
35 |
Correct |
74 ms |
10836 KB |
Output is correct |
36 |
Correct |
73 ms |
10832 KB |
Output is correct |
37 |
Correct |
72 ms |
10832 KB |
Output is correct |
38 |
Correct |
72 ms |
10832 KB |
Output is correct |
39 |
Correct |
71 ms |
11092 KB |
Output is correct |
40 |
Correct |
75 ms |
10832 KB |
Output is correct |
41 |
Correct |
85 ms |
10832 KB |
Output is correct |
42 |
Correct |
72 ms |
10836 KB |
Output is correct |
43 |
Correct |
155 ms |
10836 KB |
Output is correct |
44 |
Correct |
153 ms |
11600 KB |
Output is correct |
45 |
Correct |
157 ms |
11752 KB |
Output is correct |
46 |
Correct |
155 ms |
11744 KB |
Output is correct |
47 |
Correct |
154 ms |
11576 KB |
Output is correct |
48 |
Correct |
155 ms |
11748 KB |
Output is correct |
49 |
Correct |
159 ms |
11748 KB |
Output is correct |
50 |
Correct |
157 ms |
11580 KB |
Output is correct |
51 |
Correct |
153 ms |
11604 KB |
Output is correct |
52 |
Correct |
157 ms |
11856 KB |
Output is correct |
53 |
Correct |
160 ms |
11580 KB |
Output is correct |
54 |
Correct |
154 ms |
11604 KB |
Output is correct |
55 |
Correct |
154 ms |
11604 KB |
Output is correct |
56 |
Correct |
153 ms |
11600 KB |
Output is correct |
57 |
Correct |
156 ms |
11572 KB |
Output is correct |
58 |
Correct |
155 ms |
11604 KB |
Output is correct |
59 |
Correct |
159 ms |
11744 KB |
Output is correct |
60 |
Correct |
176 ms |
11728 KB |
Output is correct |
61 |
Correct |
153 ms |
11604 KB |
Output is correct |
62 |
Correct |
154 ms |
11604 KB |
Output is correct |
63 |
Correct |
152 ms |
11604 KB |
Output is correct |
64 |
Execution timed out |
1171 ms |
13652 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |