#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define RREP1(i, n) for (int i=(n); i>=1; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define pip pair<int, pii>
#define ppi pair<pii, int>
#define ppp pair<pii, pii>
#define pdd pair<double ,double>
#define pcc pair<char, char>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#endif
const ll inf = 1ll<<60;
const ll iinf = 2147483647;
const ll mod = 998244353;
const ll maxn=1e6+5;
const double PI=acos(-1);
ll pw(ll x, ll p, ll m=mod){
ll ret=1;
while (p>0){
if (p&1){
ret*=x;
ret%=m;
}
x*=x;
x%=m;
p>>=1;
}
return ret;
}
ll inv(ll a, ll m=mod){
return pw(a,m-2,m);
}
int n;
int cnt[62][62][11];
int ou[62][62][62][11];
int cv(char k){
if (k>='a' && k<='z'){
return (k-'a');
}
else if (k>='A' && k<='Z'){
return (k-'A')+26;
}
else return (k-'0')+52;
}
signed main(){
IOS();
cin>>n;
map<string, bool> mp;
REP(i, n){
string str; cin>>str;
mp[str]=1;
reverse(ALL(str));
mp[str]=1;
}
for (auto x:mp){
cnt[cv(x.f[0])][cv(x.f[SZ(x.f)-1])][SZ(x.f)]++;
}
int ans = 0;
int tot = 0;
FOR(l, 3, 11){
REP(i, 62){
FOR(j, i, 62){
FOR(k, j, 62){
REP(t, 62){
ou[i][j][k][l] += (cnt[i][t][l]*cnt[j][t][l]*cnt[k][t][l])%mod;
if (ou[i][j][k][l] >= mod) ou[i][j][k][l] -= mod;
}
}
}
}
int tmp;
REP(a, 62){
FOR(b, a, 62){
FOR(c, b, 62){
FOR(d, c, 62){
tmp = ou[a][b][c][l]*ou[a][b][d][l]%mod*ou[a][c][d][l]%mod*ou[b][c][d][l]%mod;
if (a == d);
else if (a == c || b == d) tmp *= 4;
else if (a == b && c == d) tmp *= 6;
else if (a == b || b == c || c == d) tmp *= 12;
else tmp *= 24;
tot = (tot+tmp)%mod;
}
}
}
}
}
cout<<tot<<endl;
}
Compilation message
cubeword.cpp: In function 'int main()':
cubeword.cpp:81:9: warning: unused variable 'ans' [-Wunused-variable]
81 | int ans = 0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
194 ms |
26704 KB |
Output is correct |
2 |
Correct |
203 ms |
27588 KB |
Output is correct |
3 |
Correct |
197 ms |
27488 KB |
Output is correct |
4 |
Correct |
198 ms |
27468 KB |
Output is correct |
5 |
Correct |
196 ms |
27580 KB |
Output is correct |
6 |
Correct |
208 ms |
27648 KB |
Output is correct |
7 |
Correct |
204 ms |
27660 KB |
Output is correct |
8 |
Correct |
219 ms |
27800 KB |
Output is correct |
9 |
Correct |
197 ms |
27472 KB |
Output is correct |
10 |
Correct |
210 ms |
27720 KB |
Output is correct |
11 |
Correct |
202 ms |
27472 KB |
Output is correct |
12 |
Correct |
211 ms |
27472 KB |
Output is correct |
13 |
Correct |
199 ms |
27472 KB |
Output is correct |
14 |
Correct |
198 ms |
27472 KB |
Output is correct |
15 |
Correct |
200 ms |
27472 KB |
Output is correct |
16 |
Correct |
197 ms |
27472 KB |
Output is correct |
17 |
Correct |
193 ms |
27472 KB |
Output is correct |
18 |
Correct |
194 ms |
27472 KB |
Output is correct |
19 |
Correct |
201 ms |
27612 KB |
Output is correct |
20 |
Correct |
204 ms |
27472 KB |
Output is correct |
21 |
Correct |
201 ms |
27728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
194 ms |
26704 KB |
Output is correct |
2 |
Correct |
203 ms |
27588 KB |
Output is correct |
3 |
Correct |
197 ms |
27488 KB |
Output is correct |
4 |
Correct |
198 ms |
27468 KB |
Output is correct |
5 |
Correct |
196 ms |
27580 KB |
Output is correct |
6 |
Correct |
208 ms |
27648 KB |
Output is correct |
7 |
Correct |
204 ms |
27660 KB |
Output is correct |
8 |
Correct |
219 ms |
27800 KB |
Output is correct |
9 |
Correct |
197 ms |
27472 KB |
Output is correct |
10 |
Correct |
210 ms |
27720 KB |
Output is correct |
11 |
Correct |
202 ms |
27472 KB |
Output is correct |
12 |
Correct |
211 ms |
27472 KB |
Output is correct |
13 |
Correct |
199 ms |
27472 KB |
Output is correct |
14 |
Correct |
198 ms |
27472 KB |
Output is correct |
15 |
Correct |
200 ms |
27472 KB |
Output is correct |
16 |
Correct |
197 ms |
27472 KB |
Output is correct |
17 |
Correct |
193 ms |
27472 KB |
Output is correct |
18 |
Correct |
194 ms |
27472 KB |
Output is correct |
19 |
Correct |
201 ms |
27612 KB |
Output is correct |
20 |
Correct |
204 ms |
27472 KB |
Output is correct |
21 |
Correct |
201 ms |
27728 KB |
Output is correct |
22 |
Correct |
202 ms |
28240 KB |
Output is correct |
23 |
Correct |
193 ms |
28144 KB |
Output is correct |
24 |
Correct |
196 ms |
28244 KB |
Output is correct |
25 |
Correct |
197 ms |
27984 KB |
Output is correct |
26 |
Correct |
198 ms |
27984 KB |
Output is correct |
27 |
Correct |
206 ms |
28156 KB |
Output is correct |
28 |
Correct |
200 ms |
27984 KB |
Output is correct |
29 |
Correct |
209 ms |
28496 KB |
Output is correct |
30 |
Correct |
197 ms |
27984 KB |
Output is correct |
31 |
Correct |
205 ms |
28256 KB |
Output is correct |
32 |
Correct |
199 ms |
28208 KB |
Output is correct |
33 |
Correct |
198 ms |
27984 KB |
Output is correct |
34 |
Correct |
196 ms |
28240 KB |
Output is correct |
35 |
Correct |
198 ms |
28168 KB |
Output is correct |
36 |
Correct |
197 ms |
28240 KB |
Output is correct |
37 |
Correct |
206 ms |
27984 KB |
Output is correct |
38 |
Correct |
199 ms |
28208 KB |
Output is correct |
39 |
Correct |
195 ms |
28072 KB |
Output is correct |
40 |
Correct |
202 ms |
28240 KB |
Output is correct |
41 |
Correct |
195 ms |
27988 KB |
Output is correct |
42 |
Correct |
203 ms |
28240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
194 ms |
26704 KB |
Output is correct |
2 |
Correct |
203 ms |
27588 KB |
Output is correct |
3 |
Correct |
197 ms |
27488 KB |
Output is correct |
4 |
Correct |
198 ms |
27468 KB |
Output is correct |
5 |
Correct |
196 ms |
27580 KB |
Output is correct |
6 |
Correct |
208 ms |
27648 KB |
Output is correct |
7 |
Correct |
204 ms |
27660 KB |
Output is correct |
8 |
Correct |
219 ms |
27800 KB |
Output is correct |
9 |
Correct |
197 ms |
27472 KB |
Output is correct |
10 |
Correct |
210 ms |
27720 KB |
Output is correct |
11 |
Correct |
202 ms |
27472 KB |
Output is correct |
12 |
Correct |
211 ms |
27472 KB |
Output is correct |
13 |
Correct |
199 ms |
27472 KB |
Output is correct |
14 |
Correct |
198 ms |
27472 KB |
Output is correct |
15 |
Correct |
200 ms |
27472 KB |
Output is correct |
16 |
Correct |
197 ms |
27472 KB |
Output is correct |
17 |
Correct |
193 ms |
27472 KB |
Output is correct |
18 |
Correct |
194 ms |
27472 KB |
Output is correct |
19 |
Correct |
201 ms |
27612 KB |
Output is correct |
20 |
Correct |
204 ms |
27472 KB |
Output is correct |
21 |
Correct |
201 ms |
27728 KB |
Output is correct |
22 |
Correct |
202 ms |
28240 KB |
Output is correct |
23 |
Correct |
193 ms |
28144 KB |
Output is correct |
24 |
Correct |
196 ms |
28244 KB |
Output is correct |
25 |
Correct |
197 ms |
27984 KB |
Output is correct |
26 |
Correct |
198 ms |
27984 KB |
Output is correct |
27 |
Correct |
206 ms |
28156 KB |
Output is correct |
28 |
Correct |
200 ms |
27984 KB |
Output is correct |
29 |
Correct |
209 ms |
28496 KB |
Output is correct |
30 |
Correct |
197 ms |
27984 KB |
Output is correct |
31 |
Correct |
205 ms |
28256 KB |
Output is correct |
32 |
Correct |
199 ms |
28208 KB |
Output is correct |
33 |
Correct |
198 ms |
27984 KB |
Output is correct |
34 |
Correct |
196 ms |
28240 KB |
Output is correct |
35 |
Correct |
198 ms |
28168 KB |
Output is correct |
36 |
Correct |
197 ms |
28240 KB |
Output is correct |
37 |
Correct |
206 ms |
27984 KB |
Output is correct |
38 |
Correct |
199 ms |
28208 KB |
Output is correct |
39 |
Correct |
195 ms |
28072 KB |
Output is correct |
40 |
Correct |
202 ms |
28240 KB |
Output is correct |
41 |
Correct |
195 ms |
27988 KB |
Output is correct |
42 |
Correct |
203 ms |
28240 KB |
Output is correct |
43 |
Correct |
207 ms |
28240 KB |
Output is correct |
44 |
Correct |
204 ms |
28240 KB |
Output is correct |
45 |
Correct |
211 ms |
28472 KB |
Output is correct |
46 |
Correct |
201 ms |
28368 KB |
Output is correct |
47 |
Correct |
194 ms |
28436 KB |
Output is correct |
48 |
Correct |
198 ms |
28244 KB |
Output is correct |
49 |
Correct |
204 ms |
28296 KB |
Output is correct |
50 |
Correct |
210 ms |
28488 KB |
Output is correct |
51 |
Correct |
196 ms |
28240 KB |
Output is correct |
52 |
Correct |
204 ms |
28552 KB |
Output is correct |
53 |
Correct |
200 ms |
28444 KB |
Output is correct |
54 |
Correct |
201 ms |
28240 KB |
Output is correct |
55 |
Correct |
201 ms |
28240 KB |
Output is correct |
56 |
Correct |
199 ms |
28240 KB |
Output is correct |
57 |
Correct |
197 ms |
28240 KB |
Output is correct |
58 |
Correct |
196 ms |
28240 KB |
Output is correct |
59 |
Correct |
195 ms |
28240 KB |
Output is correct |
60 |
Correct |
199 ms |
28464 KB |
Output is correct |
61 |
Correct |
212 ms |
28572 KB |
Output is correct |
62 |
Correct |
197 ms |
28336 KB |
Output is correct |
63 |
Correct |
207 ms |
28692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
194 ms |
26704 KB |
Output is correct |
2 |
Correct |
203 ms |
27588 KB |
Output is correct |
3 |
Correct |
197 ms |
27488 KB |
Output is correct |
4 |
Correct |
198 ms |
27468 KB |
Output is correct |
5 |
Correct |
196 ms |
27580 KB |
Output is correct |
6 |
Correct |
208 ms |
27648 KB |
Output is correct |
7 |
Correct |
204 ms |
27660 KB |
Output is correct |
8 |
Correct |
219 ms |
27800 KB |
Output is correct |
9 |
Correct |
197 ms |
27472 KB |
Output is correct |
10 |
Correct |
210 ms |
27720 KB |
Output is correct |
11 |
Correct |
202 ms |
27472 KB |
Output is correct |
12 |
Correct |
211 ms |
27472 KB |
Output is correct |
13 |
Correct |
199 ms |
27472 KB |
Output is correct |
14 |
Correct |
198 ms |
27472 KB |
Output is correct |
15 |
Correct |
200 ms |
27472 KB |
Output is correct |
16 |
Correct |
197 ms |
27472 KB |
Output is correct |
17 |
Correct |
193 ms |
27472 KB |
Output is correct |
18 |
Correct |
194 ms |
27472 KB |
Output is correct |
19 |
Correct |
201 ms |
27612 KB |
Output is correct |
20 |
Correct |
204 ms |
27472 KB |
Output is correct |
21 |
Correct |
201 ms |
27728 KB |
Output is correct |
22 |
Correct |
202 ms |
28240 KB |
Output is correct |
23 |
Correct |
193 ms |
28144 KB |
Output is correct |
24 |
Correct |
196 ms |
28244 KB |
Output is correct |
25 |
Correct |
197 ms |
27984 KB |
Output is correct |
26 |
Correct |
198 ms |
27984 KB |
Output is correct |
27 |
Correct |
206 ms |
28156 KB |
Output is correct |
28 |
Correct |
200 ms |
27984 KB |
Output is correct |
29 |
Correct |
209 ms |
28496 KB |
Output is correct |
30 |
Correct |
197 ms |
27984 KB |
Output is correct |
31 |
Correct |
205 ms |
28256 KB |
Output is correct |
32 |
Correct |
199 ms |
28208 KB |
Output is correct |
33 |
Correct |
198 ms |
27984 KB |
Output is correct |
34 |
Correct |
196 ms |
28240 KB |
Output is correct |
35 |
Correct |
198 ms |
28168 KB |
Output is correct |
36 |
Correct |
197 ms |
28240 KB |
Output is correct |
37 |
Correct |
206 ms |
27984 KB |
Output is correct |
38 |
Correct |
199 ms |
28208 KB |
Output is correct |
39 |
Correct |
195 ms |
28072 KB |
Output is correct |
40 |
Correct |
202 ms |
28240 KB |
Output is correct |
41 |
Correct |
195 ms |
27988 KB |
Output is correct |
42 |
Correct |
203 ms |
28240 KB |
Output is correct |
43 |
Correct |
207 ms |
28240 KB |
Output is correct |
44 |
Correct |
204 ms |
28240 KB |
Output is correct |
45 |
Correct |
211 ms |
28472 KB |
Output is correct |
46 |
Correct |
201 ms |
28368 KB |
Output is correct |
47 |
Correct |
194 ms |
28436 KB |
Output is correct |
48 |
Correct |
198 ms |
28244 KB |
Output is correct |
49 |
Correct |
204 ms |
28296 KB |
Output is correct |
50 |
Correct |
210 ms |
28488 KB |
Output is correct |
51 |
Correct |
196 ms |
28240 KB |
Output is correct |
52 |
Correct |
204 ms |
28552 KB |
Output is correct |
53 |
Correct |
200 ms |
28444 KB |
Output is correct |
54 |
Correct |
201 ms |
28240 KB |
Output is correct |
55 |
Correct |
201 ms |
28240 KB |
Output is correct |
56 |
Correct |
199 ms |
28240 KB |
Output is correct |
57 |
Correct |
197 ms |
28240 KB |
Output is correct |
58 |
Correct |
196 ms |
28240 KB |
Output is correct |
59 |
Correct |
195 ms |
28240 KB |
Output is correct |
60 |
Correct |
199 ms |
28464 KB |
Output is correct |
61 |
Correct |
212 ms |
28572 KB |
Output is correct |
62 |
Correct |
197 ms |
28336 KB |
Output is correct |
63 |
Correct |
207 ms |
28692 KB |
Output is correct |
64 |
Correct |
200 ms |
28708 KB |
Output is correct |
65 |
Correct |
204 ms |
28752 KB |
Output is correct |
66 |
Correct |
202 ms |
28596 KB |
Output is correct |
67 |
Correct |
206 ms |
28756 KB |
Output is correct |
68 |
Correct |
196 ms |
28752 KB |
Output is correct |
69 |
Correct |
212 ms |
29204 KB |
Output is correct |
70 |
Correct |
203 ms |
28764 KB |
Output is correct |
71 |
Correct |
217 ms |
29044 KB |
Output is correct |
72 |
Correct |
199 ms |
28752 KB |
Output is correct |
73 |
Correct |
210 ms |
29280 KB |
Output is correct |
74 |
Correct |
196 ms |
28688 KB |
Output is correct |
75 |
Correct |
198 ms |
28752 KB |
Output is correct |
76 |
Correct |
198 ms |
28708 KB |
Output is correct |
77 |
Correct |
199 ms |
28752 KB |
Output is correct |
78 |
Correct |
196 ms |
28748 KB |
Output is correct |
79 |
Correct |
204 ms |
28752 KB |
Output is correct |
80 |
Correct |
198 ms |
28752 KB |
Output is correct |
81 |
Correct |
207 ms |
28752 KB |
Output is correct |
82 |
Correct |
207 ms |
28752 KB |
Output is correct |
83 |
Correct |
195 ms |
28796 KB |
Output is correct |
84 |
Correct |
204 ms |
28876 KB |
Output is correct |