# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
379377 |
2021-03-18T04:55:29 Z |
YJU |
Cubeword (CEOI19_cubeword) |
C++14 |
|
340 ms |
17232 KB |
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector,Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll N=62;
const ll MOD=998244353;
const ll INF=(1LL<<58);
const ld pi=acos(-1);
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
#define ALL(_a) _a.begin(),_a.end()
ll ans,cnt[11][N][N],n,ccc[11][N][N][N],fac[5],is[N];
string s;
vector<string> v;
ll rev(char ch){
if('a'<=ch&&ch<='z')return (ll)ch-'a';
if('A'<=ch&&ch<='Z')return (ll)26+ch-'A';
return (ll)52+ch-'0';
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
fac[0]=1;
REP1(i,4)fac[i]=fac[i-1]*i;
cin>>n;
REP(i,n){
cin>>s;
v.pb(s);
reverse(s.begin(),s.end());
v.pb(s);
}
sort(v.begin(),v.end());
v.erase(unique(v.begin(),v.end()),v.end());
for(auto i:v){
++cnt[SZ(i)][rev(i[0])][rev(i[SZ(i)-1])];
}
for(int len=3;len<=10;++len){
REP(i,N)REP(j,i+1)REP(k,j+1){
REP(chose,N){
ccc[len][i][j][k]+=cnt[len][i][chose]*cnt[len][j][chose]*cnt[len][k][chose]%MOD;
if(ccc[len][i][j][k]>=MOD)ccc[len][i][j][k]-=MOD;
}
}
}
for(int len=3;len<=10;++len){
REP(i,N)REP(j,i+1)REP(k,j+1)REP(l,k+1){
++is[i];++is[j];++is[k];++is[l];
ll val=fac[4];
if(is[i])val/=fac[is[i]],is[i]=0;
if(is[j])val/=fac[is[j]],is[j]=0;
if(is[k])val/=fac[is[k]],is[k]=0;
if(is[l])val/=fac[is[l]],is[l]=0;
ll a=ccc[len][i][j][k],b=ccc[len][i][j][l],c=ccc[len][i][k][l],d=ccc[len][j][k][l];
ans+=(a*b%MOD*c%MOD*d%MOD)*val;
ans%=MOD;
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
328 ms |
17232 KB |
Output is correct |
2 |
Correct |
339 ms |
16976 KB |
Output is correct |
3 |
Correct |
309 ms |
16976 KB |
Output is correct |
4 |
Correct |
310 ms |
16976 KB |
Output is correct |
5 |
Correct |
316 ms |
16976 KB |
Output is correct |
6 |
Correct |
309 ms |
16976 KB |
Output is correct |
7 |
Correct |
314 ms |
17004 KB |
Output is correct |
8 |
Correct |
324 ms |
16976 KB |
Output is correct |
9 |
Correct |
314 ms |
16976 KB |
Output is correct |
10 |
Correct |
324 ms |
17104 KB |
Output is correct |
11 |
Correct |
316 ms |
16976 KB |
Output is correct |
12 |
Correct |
310 ms |
16976 KB |
Output is correct |
13 |
Correct |
318 ms |
16976 KB |
Output is correct |
14 |
Correct |
325 ms |
16976 KB |
Output is correct |
15 |
Correct |
311 ms |
16976 KB |
Output is correct |
16 |
Correct |
312 ms |
17104 KB |
Output is correct |
17 |
Correct |
310 ms |
16976 KB |
Output is correct |
18 |
Correct |
311 ms |
16976 KB |
Output is correct |
19 |
Correct |
306 ms |
16976 KB |
Output is correct |
20 |
Correct |
310 ms |
16976 KB |
Output is correct |
21 |
Correct |
328 ms |
16904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
328 ms |
17232 KB |
Output is correct |
2 |
Correct |
339 ms |
16976 KB |
Output is correct |
3 |
Correct |
309 ms |
16976 KB |
Output is correct |
4 |
Correct |
310 ms |
16976 KB |
Output is correct |
5 |
Correct |
316 ms |
16976 KB |
Output is correct |
6 |
Correct |
309 ms |
16976 KB |
Output is correct |
7 |
Correct |
314 ms |
17004 KB |
Output is correct |
8 |
Correct |
324 ms |
16976 KB |
Output is correct |
9 |
Correct |
314 ms |
16976 KB |
Output is correct |
10 |
Correct |
324 ms |
17104 KB |
Output is correct |
11 |
Correct |
316 ms |
16976 KB |
Output is correct |
12 |
Correct |
310 ms |
16976 KB |
Output is correct |
13 |
Correct |
318 ms |
16976 KB |
Output is correct |
14 |
Correct |
325 ms |
16976 KB |
Output is correct |
15 |
Correct |
311 ms |
16976 KB |
Output is correct |
16 |
Correct |
312 ms |
17104 KB |
Output is correct |
17 |
Correct |
310 ms |
16976 KB |
Output is correct |
18 |
Correct |
311 ms |
16976 KB |
Output is correct |
19 |
Correct |
306 ms |
16976 KB |
Output is correct |
20 |
Correct |
310 ms |
16976 KB |
Output is correct |
21 |
Correct |
328 ms |
16904 KB |
Output is correct |
22 |
Correct |
312 ms |
16848 KB |
Output is correct |
23 |
Correct |
305 ms |
16848 KB |
Output is correct |
24 |
Correct |
307 ms |
16944 KB |
Output is correct |
25 |
Correct |
340 ms |
16908 KB |
Output is correct |
26 |
Correct |
312 ms |
16976 KB |
Output is correct |
27 |
Correct |
309 ms |
16848 KB |
Output is correct |
28 |
Correct |
337 ms |
16944 KB |
Output is correct |
29 |
Correct |
307 ms |
16976 KB |
Output is correct |
30 |
Correct |
318 ms |
16876 KB |
Output is correct |
31 |
Correct |
316 ms |
16976 KB |
Output is correct |
32 |
Correct |
307 ms |
17104 KB |
Output is correct |
33 |
Correct |
314 ms |
16976 KB |
Output is correct |
34 |
Correct |
319 ms |
16848 KB |
Output is correct |
35 |
Correct |
312 ms |
16976 KB |
Output is correct |
36 |
Correct |
311 ms |
16976 KB |
Output is correct |
37 |
Correct |
309 ms |
16976 KB |
Output is correct |
38 |
Correct |
312 ms |
16848 KB |
Output is correct |
39 |
Correct |
314 ms |
16976 KB |
Output is correct |
40 |
Correct |
323 ms |
16976 KB |
Output is correct |
41 |
Correct |
306 ms |
16848 KB |
Output is correct |
42 |
Correct |
319 ms |
17000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
328 ms |
17232 KB |
Output is correct |
2 |
Correct |
339 ms |
16976 KB |
Output is correct |
3 |
Correct |
309 ms |
16976 KB |
Output is correct |
4 |
Correct |
310 ms |
16976 KB |
Output is correct |
5 |
Correct |
316 ms |
16976 KB |
Output is correct |
6 |
Correct |
309 ms |
16976 KB |
Output is correct |
7 |
Correct |
314 ms |
17004 KB |
Output is correct |
8 |
Correct |
324 ms |
16976 KB |
Output is correct |
9 |
Correct |
314 ms |
16976 KB |
Output is correct |
10 |
Correct |
324 ms |
17104 KB |
Output is correct |
11 |
Correct |
316 ms |
16976 KB |
Output is correct |
12 |
Correct |
310 ms |
16976 KB |
Output is correct |
13 |
Correct |
318 ms |
16976 KB |
Output is correct |
14 |
Correct |
325 ms |
16976 KB |
Output is correct |
15 |
Correct |
311 ms |
16976 KB |
Output is correct |
16 |
Correct |
312 ms |
17104 KB |
Output is correct |
17 |
Correct |
310 ms |
16976 KB |
Output is correct |
18 |
Correct |
311 ms |
16976 KB |
Output is correct |
19 |
Correct |
306 ms |
16976 KB |
Output is correct |
20 |
Correct |
310 ms |
16976 KB |
Output is correct |
21 |
Correct |
328 ms |
16904 KB |
Output is correct |
22 |
Correct |
312 ms |
16848 KB |
Output is correct |
23 |
Correct |
305 ms |
16848 KB |
Output is correct |
24 |
Correct |
307 ms |
16944 KB |
Output is correct |
25 |
Correct |
340 ms |
16908 KB |
Output is correct |
26 |
Correct |
312 ms |
16976 KB |
Output is correct |
27 |
Correct |
309 ms |
16848 KB |
Output is correct |
28 |
Correct |
337 ms |
16944 KB |
Output is correct |
29 |
Correct |
307 ms |
16976 KB |
Output is correct |
30 |
Correct |
318 ms |
16876 KB |
Output is correct |
31 |
Correct |
316 ms |
16976 KB |
Output is correct |
32 |
Correct |
307 ms |
17104 KB |
Output is correct |
33 |
Correct |
314 ms |
16976 KB |
Output is correct |
34 |
Correct |
319 ms |
16848 KB |
Output is correct |
35 |
Correct |
312 ms |
16976 KB |
Output is correct |
36 |
Correct |
311 ms |
16976 KB |
Output is correct |
37 |
Correct |
309 ms |
16976 KB |
Output is correct |
38 |
Correct |
312 ms |
16848 KB |
Output is correct |
39 |
Correct |
314 ms |
16976 KB |
Output is correct |
40 |
Correct |
323 ms |
16976 KB |
Output is correct |
41 |
Correct |
306 ms |
16848 KB |
Output is correct |
42 |
Correct |
319 ms |
17000 KB |
Output is correct |
43 |
Correct |
325 ms |
16976 KB |
Output is correct |
44 |
Correct |
311 ms |
16944 KB |
Output is correct |
45 |
Correct |
309 ms |
16976 KB |
Output is correct |
46 |
Correct |
311 ms |
16976 KB |
Output is correct |
47 |
Correct |
305 ms |
16976 KB |
Output is correct |
48 |
Correct |
310 ms |
16976 KB |
Output is correct |
49 |
Correct |
309 ms |
16956 KB |
Output is correct |
50 |
Correct |
305 ms |
16976 KB |
Output is correct |
51 |
Correct |
306 ms |
16976 KB |
Output is correct |
52 |
Correct |
330 ms |
16976 KB |
Output is correct |
53 |
Correct |
307 ms |
16976 KB |
Output is correct |
54 |
Correct |
308 ms |
16976 KB |
Output is correct |
55 |
Correct |
319 ms |
17104 KB |
Output is correct |
56 |
Correct |
313 ms |
16916 KB |
Output is correct |
57 |
Correct |
311 ms |
16976 KB |
Output is correct |
58 |
Correct |
310 ms |
16976 KB |
Output is correct |
59 |
Correct |
314 ms |
16976 KB |
Output is correct |
60 |
Correct |
316 ms |
17108 KB |
Output is correct |
61 |
Correct |
309 ms |
16976 KB |
Output is correct |
62 |
Correct |
305 ms |
16976 KB |
Output is correct |
63 |
Correct |
319 ms |
16976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
328 ms |
17232 KB |
Output is correct |
2 |
Correct |
339 ms |
16976 KB |
Output is correct |
3 |
Correct |
309 ms |
16976 KB |
Output is correct |
4 |
Correct |
310 ms |
16976 KB |
Output is correct |
5 |
Correct |
316 ms |
16976 KB |
Output is correct |
6 |
Correct |
309 ms |
16976 KB |
Output is correct |
7 |
Correct |
314 ms |
17004 KB |
Output is correct |
8 |
Correct |
324 ms |
16976 KB |
Output is correct |
9 |
Correct |
314 ms |
16976 KB |
Output is correct |
10 |
Correct |
324 ms |
17104 KB |
Output is correct |
11 |
Correct |
316 ms |
16976 KB |
Output is correct |
12 |
Correct |
310 ms |
16976 KB |
Output is correct |
13 |
Correct |
318 ms |
16976 KB |
Output is correct |
14 |
Correct |
325 ms |
16976 KB |
Output is correct |
15 |
Correct |
311 ms |
16976 KB |
Output is correct |
16 |
Correct |
312 ms |
17104 KB |
Output is correct |
17 |
Correct |
310 ms |
16976 KB |
Output is correct |
18 |
Correct |
311 ms |
16976 KB |
Output is correct |
19 |
Correct |
306 ms |
16976 KB |
Output is correct |
20 |
Correct |
310 ms |
16976 KB |
Output is correct |
21 |
Correct |
328 ms |
16904 KB |
Output is correct |
22 |
Correct |
312 ms |
16848 KB |
Output is correct |
23 |
Correct |
305 ms |
16848 KB |
Output is correct |
24 |
Correct |
307 ms |
16944 KB |
Output is correct |
25 |
Correct |
340 ms |
16908 KB |
Output is correct |
26 |
Correct |
312 ms |
16976 KB |
Output is correct |
27 |
Correct |
309 ms |
16848 KB |
Output is correct |
28 |
Correct |
337 ms |
16944 KB |
Output is correct |
29 |
Correct |
307 ms |
16976 KB |
Output is correct |
30 |
Correct |
318 ms |
16876 KB |
Output is correct |
31 |
Correct |
316 ms |
16976 KB |
Output is correct |
32 |
Correct |
307 ms |
17104 KB |
Output is correct |
33 |
Correct |
314 ms |
16976 KB |
Output is correct |
34 |
Correct |
319 ms |
16848 KB |
Output is correct |
35 |
Correct |
312 ms |
16976 KB |
Output is correct |
36 |
Correct |
311 ms |
16976 KB |
Output is correct |
37 |
Correct |
309 ms |
16976 KB |
Output is correct |
38 |
Correct |
312 ms |
16848 KB |
Output is correct |
39 |
Correct |
314 ms |
16976 KB |
Output is correct |
40 |
Correct |
323 ms |
16976 KB |
Output is correct |
41 |
Correct |
306 ms |
16848 KB |
Output is correct |
42 |
Correct |
319 ms |
17000 KB |
Output is correct |
43 |
Correct |
325 ms |
16976 KB |
Output is correct |
44 |
Correct |
311 ms |
16944 KB |
Output is correct |
45 |
Correct |
309 ms |
16976 KB |
Output is correct |
46 |
Correct |
311 ms |
16976 KB |
Output is correct |
47 |
Correct |
305 ms |
16976 KB |
Output is correct |
48 |
Correct |
310 ms |
16976 KB |
Output is correct |
49 |
Correct |
309 ms |
16956 KB |
Output is correct |
50 |
Correct |
305 ms |
16976 KB |
Output is correct |
51 |
Correct |
306 ms |
16976 KB |
Output is correct |
52 |
Correct |
330 ms |
16976 KB |
Output is correct |
53 |
Correct |
307 ms |
16976 KB |
Output is correct |
54 |
Correct |
308 ms |
16976 KB |
Output is correct |
55 |
Correct |
319 ms |
17104 KB |
Output is correct |
56 |
Correct |
313 ms |
16916 KB |
Output is correct |
57 |
Correct |
311 ms |
16976 KB |
Output is correct |
58 |
Correct |
310 ms |
16976 KB |
Output is correct |
59 |
Correct |
314 ms |
16976 KB |
Output is correct |
60 |
Correct |
316 ms |
17108 KB |
Output is correct |
61 |
Correct |
309 ms |
16976 KB |
Output is correct |
62 |
Correct |
305 ms |
16976 KB |
Output is correct |
63 |
Correct |
319 ms |
16976 KB |
Output is correct |
64 |
Correct |
304 ms |
16976 KB |
Output is correct |
65 |
Correct |
304 ms |
17016 KB |
Output is correct |
66 |
Correct |
310 ms |
16976 KB |
Output is correct |
67 |
Correct |
313 ms |
17068 KB |
Output is correct |
68 |
Correct |
305 ms |
16976 KB |
Output is correct |
69 |
Correct |
311 ms |
17020 KB |
Output is correct |
70 |
Correct |
305 ms |
17104 KB |
Output is correct |
71 |
Correct |
320 ms |
16976 KB |
Output is correct |
72 |
Correct |
335 ms |
16976 KB |
Output is correct |
73 |
Correct |
305 ms |
16976 KB |
Output is correct |
74 |
Correct |
318 ms |
17104 KB |
Output is correct |
75 |
Correct |
336 ms |
17036 KB |
Output is correct |
76 |
Correct |
310 ms |
16976 KB |
Output is correct |
77 |
Correct |
309 ms |
16976 KB |
Output is correct |
78 |
Correct |
306 ms |
17104 KB |
Output is correct |
79 |
Correct |
314 ms |
17040 KB |
Output is correct |
80 |
Correct |
313 ms |
16976 KB |
Output is correct |
81 |
Correct |
307 ms |
17036 KB |
Output is correct |
82 |
Correct |
311 ms |
16976 KB |
Output is correct |
83 |
Correct |
307 ms |
17036 KB |
Output is correct |
84 |
Correct |
313 ms |
16976 KB |
Output is correct |