#include <bits/stdc++.h>
#define int long long
using namespace std;
const int Nmax=100010, M=52, Mod=998244353;
int N, ans, cnt[M][M], val[M][M][M];
string S[Nmax];
int f(char x) {
if('a'<=x && x<='z') return x-'a';
else if('A'<=x && x<='Z') return x-'A'+26;
else return x-'0'+52;
}
void solve(vector<string> V) {
map<string, bool> chk;
for(int i=0; i<V.size(); i++) {
string tmp=V[i];
reverse(tmp.begin(), tmp.end());
if(chk[tmp]) {
swap(V[i], V.back()); V.pop_back();
i--; continue;
}
chk[V[i]]=true;
}
for(int i=0; i<M; i++) for(int j=0; j<M; j++) cnt[i][j]=0;
for(int i=0; i<V.size(); i++) {
int l=f(V[i][0]), r=f(V[i].back());
cnt[l][r]++;
string t=V[i]; reverse(t.begin(), t.end());
if(l!=r || V[i]!=t) cnt[r][l]++;
}
for(int i=0; i<M; i++) for(int j=0; j<M; j++) for(int k=0; k<M; k++) {
val[i][j][k]=0;
for(int l=0; l<M; l++) val[i][j][k]=(val[i][j][k]+((cnt[i][l]*cnt[j][l])%Mod)*cnt[k][l])%Mod;
}
for(int a=0; a<M; a++) for(int b=0; b<M; b++) for(int c=0; c<M; c++) for(int d=0; d<M; d++)
ans=(ans+((val[a][b][c]*val[a][b][d])%Mod)*((val[a][c][d]*val[b][c][d])%Mod))%Mod;
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>N;
for(int i=1; i<=N; i++) cin>>S[i];
for(int i=3; i<=10; i++) {
vector<string> v;
for(int j=1; j<=N; j++) if(S[j].size()==i) v.push_back(S[j]);
solve(v);
}
cout<<ans;
return 0;
}
Compilation message
cubeword.cpp: In function 'void solve(std::vector<std::__cxx11::basic_string<char> >)':
cubeword.cpp:17:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for(int i=0; i<V.size(); i++) {
| ~^~~~~~~~~
cubeword.cpp:27:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i=0; i<V.size(); i++) {
| ~^~~~~~~~~
cubeword.cpp: In function 'int main()':
cubeword.cpp:47:47: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
47 | for(int j=1; j<=N; j++) if(S[j].size()==i) v.push_back(S[j]);
| ~~~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
548 ms |
9096 KB |
Output is correct |
2 |
Correct |
558 ms |
9212 KB |
Output is correct |
3 |
Correct |
580 ms |
9276 KB |
Output is correct |
4 |
Correct |
560 ms |
9280 KB |
Output is correct |
5 |
Correct |
551 ms |
9136 KB |
Output is correct |
6 |
Correct |
563 ms |
9260 KB |
Output is correct |
7 |
Correct |
560 ms |
8924 KB |
Output is correct |
8 |
Correct |
550 ms |
9276 KB |
Output is correct |
9 |
Correct |
540 ms |
9052 KB |
Output is correct |
10 |
Correct |
543 ms |
9080 KB |
Output is correct |
11 |
Correct |
561 ms |
9300 KB |
Output is correct |
12 |
Correct |
539 ms |
9096 KB |
Output is correct |
13 |
Correct |
565 ms |
9104 KB |
Output is correct |
14 |
Correct |
545 ms |
9216 KB |
Output is correct |
15 |
Correct |
526 ms |
9312 KB |
Output is correct |
16 |
Correct |
498 ms |
9160 KB |
Output is correct |
17 |
Correct |
517 ms |
9204 KB |
Output is correct |
18 |
Correct |
530 ms |
9292 KB |
Output is correct |
19 |
Correct |
533 ms |
9188 KB |
Output is correct |
20 |
Correct |
535 ms |
9292 KB |
Output is correct |
21 |
Correct |
497 ms |
9156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
548 ms |
9096 KB |
Output is correct |
2 |
Correct |
558 ms |
9212 KB |
Output is correct |
3 |
Correct |
580 ms |
9276 KB |
Output is correct |
4 |
Correct |
560 ms |
9280 KB |
Output is correct |
5 |
Correct |
551 ms |
9136 KB |
Output is correct |
6 |
Correct |
563 ms |
9260 KB |
Output is correct |
7 |
Correct |
560 ms |
8924 KB |
Output is correct |
8 |
Correct |
550 ms |
9276 KB |
Output is correct |
9 |
Correct |
540 ms |
9052 KB |
Output is correct |
10 |
Correct |
543 ms |
9080 KB |
Output is correct |
11 |
Correct |
561 ms |
9300 KB |
Output is correct |
12 |
Correct |
539 ms |
9096 KB |
Output is correct |
13 |
Correct |
565 ms |
9104 KB |
Output is correct |
14 |
Correct |
545 ms |
9216 KB |
Output is correct |
15 |
Correct |
526 ms |
9312 KB |
Output is correct |
16 |
Correct |
498 ms |
9160 KB |
Output is correct |
17 |
Correct |
517 ms |
9204 KB |
Output is correct |
18 |
Correct |
530 ms |
9292 KB |
Output is correct |
19 |
Correct |
533 ms |
9188 KB |
Output is correct |
20 |
Correct |
535 ms |
9292 KB |
Output is correct |
21 |
Correct |
497 ms |
9156 KB |
Output is correct |
22 |
Correct |
532 ms |
7708 KB |
Output is correct |
23 |
Correct |
521 ms |
8092 KB |
Output is correct |
24 |
Correct |
523 ms |
7660 KB |
Output is correct |
25 |
Correct |
499 ms |
7648 KB |
Output is correct |
26 |
Correct |
535 ms |
7760 KB |
Output is correct |
27 |
Correct |
528 ms |
7840 KB |
Output is correct |
28 |
Correct |
547 ms |
7804 KB |
Output is correct |
29 |
Correct |
528 ms |
7684 KB |
Output is correct |
30 |
Correct |
523 ms |
7852 KB |
Output is correct |
31 |
Correct |
537 ms |
7836 KB |
Output is correct |
32 |
Correct |
530 ms |
7752 KB |
Output is correct |
33 |
Correct |
537 ms |
7840 KB |
Output is correct |
34 |
Correct |
529 ms |
7840 KB |
Output is correct |
35 |
Correct |
522 ms |
7648 KB |
Output is correct |
36 |
Correct |
525 ms |
7832 KB |
Output is correct |
37 |
Correct |
525 ms |
7844 KB |
Output is correct |
38 |
Correct |
522 ms |
7756 KB |
Output is correct |
39 |
Correct |
523 ms |
7604 KB |
Output is correct |
40 |
Correct |
531 ms |
7816 KB |
Output is correct |
41 |
Correct |
519 ms |
7660 KB |
Output is correct |
42 |
Correct |
507 ms |
7836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
548 ms |
9096 KB |
Output is correct |
2 |
Correct |
558 ms |
9212 KB |
Output is correct |
3 |
Correct |
580 ms |
9276 KB |
Output is correct |
4 |
Correct |
560 ms |
9280 KB |
Output is correct |
5 |
Correct |
551 ms |
9136 KB |
Output is correct |
6 |
Correct |
563 ms |
9260 KB |
Output is correct |
7 |
Correct |
560 ms |
8924 KB |
Output is correct |
8 |
Correct |
550 ms |
9276 KB |
Output is correct |
9 |
Correct |
540 ms |
9052 KB |
Output is correct |
10 |
Correct |
543 ms |
9080 KB |
Output is correct |
11 |
Correct |
561 ms |
9300 KB |
Output is correct |
12 |
Correct |
539 ms |
9096 KB |
Output is correct |
13 |
Correct |
565 ms |
9104 KB |
Output is correct |
14 |
Correct |
545 ms |
9216 KB |
Output is correct |
15 |
Correct |
526 ms |
9312 KB |
Output is correct |
16 |
Correct |
498 ms |
9160 KB |
Output is correct |
17 |
Correct |
517 ms |
9204 KB |
Output is correct |
18 |
Correct |
530 ms |
9292 KB |
Output is correct |
19 |
Correct |
533 ms |
9188 KB |
Output is correct |
20 |
Correct |
535 ms |
9292 KB |
Output is correct |
21 |
Correct |
497 ms |
9156 KB |
Output is correct |
22 |
Correct |
532 ms |
7708 KB |
Output is correct |
23 |
Correct |
521 ms |
8092 KB |
Output is correct |
24 |
Correct |
523 ms |
7660 KB |
Output is correct |
25 |
Correct |
499 ms |
7648 KB |
Output is correct |
26 |
Correct |
535 ms |
7760 KB |
Output is correct |
27 |
Correct |
528 ms |
7840 KB |
Output is correct |
28 |
Correct |
547 ms |
7804 KB |
Output is correct |
29 |
Correct |
528 ms |
7684 KB |
Output is correct |
30 |
Correct |
523 ms |
7852 KB |
Output is correct |
31 |
Correct |
537 ms |
7836 KB |
Output is correct |
32 |
Correct |
530 ms |
7752 KB |
Output is correct |
33 |
Correct |
537 ms |
7840 KB |
Output is correct |
34 |
Correct |
529 ms |
7840 KB |
Output is correct |
35 |
Correct |
522 ms |
7648 KB |
Output is correct |
36 |
Correct |
525 ms |
7832 KB |
Output is correct |
37 |
Correct |
525 ms |
7844 KB |
Output is correct |
38 |
Correct |
522 ms |
7756 KB |
Output is correct |
39 |
Correct |
523 ms |
7604 KB |
Output is correct |
40 |
Correct |
531 ms |
7816 KB |
Output is correct |
41 |
Correct |
519 ms |
7660 KB |
Output is correct |
42 |
Correct |
507 ms |
7836 KB |
Output is correct |
43 |
Correct |
540 ms |
7796 KB |
Output is correct |
44 |
Correct |
524 ms |
7732 KB |
Output is correct |
45 |
Correct |
517 ms |
7572 KB |
Output is correct |
46 |
Correct |
546 ms |
7464 KB |
Output is correct |
47 |
Correct |
535 ms |
7480 KB |
Output is correct |
48 |
Correct |
522 ms |
7560 KB |
Output is correct |
49 |
Correct |
509 ms |
7488 KB |
Output is correct |
50 |
Correct |
529 ms |
7592 KB |
Output is correct |
51 |
Correct |
514 ms |
7460 KB |
Output is correct |
52 |
Correct |
528 ms |
7636 KB |
Output is correct |
53 |
Correct |
528 ms |
7468 KB |
Output is correct |
54 |
Correct |
537 ms |
7724 KB |
Output is correct |
55 |
Correct |
521 ms |
7392 KB |
Output is correct |
56 |
Correct |
521 ms |
7500 KB |
Output is correct |
57 |
Correct |
520 ms |
7472 KB |
Output is correct |
58 |
Correct |
559 ms |
7568 KB |
Output is correct |
59 |
Correct |
519 ms |
7480 KB |
Output is correct |
60 |
Correct |
504 ms |
7608 KB |
Output is correct |
61 |
Correct |
520 ms |
7472 KB |
Output is correct |
62 |
Correct |
527 ms |
7472 KB |
Output is correct |
63 |
Correct |
528 ms |
7484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
548 ms |
9096 KB |
Output is correct |
2 |
Correct |
558 ms |
9212 KB |
Output is correct |
3 |
Correct |
580 ms |
9276 KB |
Output is correct |
4 |
Correct |
560 ms |
9280 KB |
Output is correct |
5 |
Correct |
551 ms |
9136 KB |
Output is correct |
6 |
Correct |
563 ms |
9260 KB |
Output is correct |
7 |
Correct |
560 ms |
8924 KB |
Output is correct |
8 |
Correct |
550 ms |
9276 KB |
Output is correct |
9 |
Correct |
540 ms |
9052 KB |
Output is correct |
10 |
Correct |
543 ms |
9080 KB |
Output is correct |
11 |
Correct |
561 ms |
9300 KB |
Output is correct |
12 |
Correct |
539 ms |
9096 KB |
Output is correct |
13 |
Correct |
565 ms |
9104 KB |
Output is correct |
14 |
Correct |
545 ms |
9216 KB |
Output is correct |
15 |
Correct |
526 ms |
9312 KB |
Output is correct |
16 |
Correct |
498 ms |
9160 KB |
Output is correct |
17 |
Correct |
517 ms |
9204 KB |
Output is correct |
18 |
Correct |
530 ms |
9292 KB |
Output is correct |
19 |
Correct |
533 ms |
9188 KB |
Output is correct |
20 |
Correct |
535 ms |
9292 KB |
Output is correct |
21 |
Correct |
497 ms |
9156 KB |
Output is correct |
22 |
Correct |
532 ms |
7708 KB |
Output is correct |
23 |
Correct |
521 ms |
8092 KB |
Output is correct |
24 |
Correct |
523 ms |
7660 KB |
Output is correct |
25 |
Correct |
499 ms |
7648 KB |
Output is correct |
26 |
Correct |
535 ms |
7760 KB |
Output is correct |
27 |
Correct |
528 ms |
7840 KB |
Output is correct |
28 |
Correct |
547 ms |
7804 KB |
Output is correct |
29 |
Correct |
528 ms |
7684 KB |
Output is correct |
30 |
Correct |
523 ms |
7852 KB |
Output is correct |
31 |
Correct |
537 ms |
7836 KB |
Output is correct |
32 |
Correct |
530 ms |
7752 KB |
Output is correct |
33 |
Correct |
537 ms |
7840 KB |
Output is correct |
34 |
Correct |
529 ms |
7840 KB |
Output is correct |
35 |
Correct |
522 ms |
7648 KB |
Output is correct |
36 |
Correct |
525 ms |
7832 KB |
Output is correct |
37 |
Correct |
525 ms |
7844 KB |
Output is correct |
38 |
Correct |
522 ms |
7756 KB |
Output is correct |
39 |
Correct |
523 ms |
7604 KB |
Output is correct |
40 |
Correct |
531 ms |
7816 KB |
Output is correct |
41 |
Correct |
519 ms |
7660 KB |
Output is correct |
42 |
Correct |
507 ms |
7836 KB |
Output is correct |
43 |
Correct |
540 ms |
7796 KB |
Output is correct |
44 |
Correct |
524 ms |
7732 KB |
Output is correct |
45 |
Correct |
517 ms |
7572 KB |
Output is correct |
46 |
Correct |
546 ms |
7464 KB |
Output is correct |
47 |
Correct |
535 ms |
7480 KB |
Output is correct |
48 |
Correct |
522 ms |
7560 KB |
Output is correct |
49 |
Correct |
509 ms |
7488 KB |
Output is correct |
50 |
Correct |
529 ms |
7592 KB |
Output is correct |
51 |
Correct |
514 ms |
7460 KB |
Output is correct |
52 |
Correct |
528 ms |
7636 KB |
Output is correct |
53 |
Correct |
528 ms |
7468 KB |
Output is correct |
54 |
Correct |
537 ms |
7724 KB |
Output is correct |
55 |
Correct |
521 ms |
7392 KB |
Output is correct |
56 |
Correct |
521 ms |
7500 KB |
Output is correct |
57 |
Correct |
520 ms |
7472 KB |
Output is correct |
58 |
Correct |
559 ms |
7568 KB |
Output is correct |
59 |
Correct |
519 ms |
7480 KB |
Output is correct |
60 |
Correct |
504 ms |
7608 KB |
Output is correct |
61 |
Correct |
520 ms |
7472 KB |
Output is correct |
62 |
Correct |
527 ms |
7472 KB |
Output is correct |
63 |
Correct |
528 ms |
7484 KB |
Output is correct |
64 |
Runtime error |
539 ms |
15000 KB |
Execution killed with signal 11 |
65 |
Halted |
0 ms |
0 KB |
- |