제출 #945925

#제출 시각아이디문제언어결과실행 시간메모리
945925MinbaevCubeword (CEOI19_cubeword)C++17
0 / 100
173 ms17940 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(),x.end() #define pb push_back const int N=1e6 + 5 ; const int inf = 1e18 + 7; const int mod = 998244353; int g[11][33][33][33]; int v[11][33][33]; int ans = 0; int n,m,k; map<char,int>mps; vector<int>vs; int ii(char ch){ return mps[ch]; } void dfs(int i){ } int cnt = 0; void solve(){ cin >> n; map<string,int>mp; for(int i = 1;i<=n;i++){ string a; cin >> a; if(mp[a] == 0){ v[a.size()][ii(a[0])][ii(a[a.size()-1])] += 1; } mp[a] += 1; reverse(all(a)); if(mp[a] == 0){ v[a.size()][ii(a[0])][ii(a[a.size()-1])] += 1; } mp[a] += 1; } for(int sz = 3;sz<=10;sz++){ for(int i = 0;i<cnt;i++){ for(int j = 0;j<cnt;j++){ for(int l = 0;l<cnt;l++){ for(int u = 0;u<cnt;u++){ g[sz][j][l][u] += ((v[sz][i][j]*v[sz][i][l]) % mod) * (v[sz][i][u])% mod; g[sz][j][l][u] %= mod; } } } } } map<int,int>pw; pw[0] = 1; pw[1] = 1; pw[2] = 2; pw[3] = 6; pw[4] = 24; for(int sz = 3;sz<=10;sz++){ for(int i = 0;i<cnt;i++){ for(int j = i;j<cnt;j++){ for(int l = j;l<cnt;l++){ for(int u = l;u<cnt;u++){ int ile=24,c=1; if(i != j){ ile /= pw[c]; c = 1; } else c += 1; if(l != j){ ile /= pw[c]; c = 1; } else c += 1; if(l != u){ ile /= pw[c]; c = 1; } else c += 1; ile /= pw[c]; ans += (((g[sz][i][j][l] * g[sz][i][j][u])% mod) * g[sz][i][l][u]) % mod * g[sz][j][l][u] % mod; ans *= ile; ans %= mod; } } } } } cout << ans << '\n'; } /* */ signed main() { for(int i = 0;i<='p'-'a';i+=1){ mps['a'+i] = cnt++; } for(int i = 0;i<='p'-'a';i+=1){ mps['A'+i] = cnt++; } ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); int tt=1;//cin>>tt>>n; while(tt--)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...