제출 #541237

#제출 시각아이디문제언어결과실행 시간메모리
541237DeepessonCubeword (CEOI19_cubeword)C++17
21 / 100
677 ms10652 KiB
#include <bits/stdc++.h> #define MAX 105000 std::vector<std::string> words[MAX]; int N; const long long MOD = 998244353; long long tabela[300][300]; void iniciar(int x){ std::map<std::string,bool> mapa; memset(&tabela[0][0],0,sizeof(tabela)); for(auto&z:words[x]){ mapa[z]=true; std::reverse(z.begin(),z.end()); mapa[z]=true; } for(auto&x:mapa){ tabela[x.first[0]-'a'][x.first.back()-'a']++; } } long long solve(void){ long long ans=0; for(int a=0;a!=6;++a){ for(int b=0;b!=6;++b){ for(int c=0;c!=6;++c){ for(int d=0;d!=6;++d){ for(int e=0;e!=6;++e){ for(int f=0;f!=6;++f){ for(int g=0;g!=6;++g){ for(int h=0;h!=6;++h){ long long vals[]={ tabela[a][b], tabela[a][c], tabela[c][d], tabela[d][b], tabela[a][f], tabela[b][e], tabela[d][h], tabela[c][g], tabela[f][g], tabela[g][h], tabela[h][e], tabela[f][e] }; long long loc=1; for(auto&x:vals)loc=(loc*x)%MOD; ans=(ans+loc)%MOD; } } } } } } } } return ans; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); std::cin>>N; for(int i=0;i!=N;++i){ std::string k; std::cin>>k; words[k.size()].push_back(k); } long long tot = 0; for(int i=3;i!=11;++i){ iniciar(i); tot = (tot+solve())%MOD; } std::cout<<tot<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...