Submission #779585

# Submission time Handle Problem Language Result Execution time Memory
779585 2023-07-11T14:37:05 Z sdgdgssdg Cubeword (CEOI19_cubeword) C++14
0 / 100
1100 ms 16740 KB
#include <bits/stdc++.h>
#define SZ 63
using ll = long long;
ll rel[SZ][SZ];
ll tuplas[SZ][SZ][SZ];
ll MOD = 998244353;
std::map<char,int> mapinha;
int cur=0;
int valor(char ch){
	if(mapinha.find(ch)!=mapinha.end())return mapinha[ch];
	mapinha[ch]=cur;
	++cur;
	return mapinha[ch];
}
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);
	int N;
	std::cin>>N;
	std::map<std::string,bool> mapa[11];
	for(int i=0;i!=N;++i){
		std::string s;
		std::cin >> s;
		mapa[s.size()][s]=1;
		std::reverse(s.begin(),s.end());
		mapa[s.size()][s]=1;
	}
	ll ans=0;
	for(int j=3;j<=10;++j){
		for(auto&x:rel)for(auto&y:x)y=0;
		for(auto&x:mapa[j]){
			rel[valor(x.first[0])][valor(x.first.back())]++;
		}
		for(int i=0;i!=SZ;++i){
			for(int j=i;j!=SZ;++j){
				for(int k=j;k!=SZ;++k){
					ll tot=0;
					for(int u=0;u!=SZ;++u)tot=(tot+((rel[i][u]*rel[j][u]%MOD)*rel[k][u]))%MOD;
					tuplas[i][j][k]=tuplas[i][k][j]=tuplas[j][i][k]=tuplas[j][k][i]=tuplas[k][i][j]=tuplas[k][j][i]=tot;
				}
			}
		}
		for(int i=0;i!=SZ;++i){
			for(int j=0;j!=SZ;++j){
				for(int k=0;k!=SZ;++k){
					for(int l=0;l!=SZ;++l){
						ans=(ans+(((tuplas[i][j][k]*tuplas[i][k][l]%MOD)*tuplas[k][l][j]%MOD)*tuplas[i][j][l]))%MOD;
					}
				}
			}
		}
	}
	std::cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1181 ms 16740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1181 ms 16740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1181 ms 16740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1181 ms 16740 KB Time limit exceeded
2 Halted 0 ms 0 KB -