답안 #949435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949435 2024-03-19T08:48:43 Z gaga999 Cubeword (CEOI19_cubeword) C++17
0 / 100
3 ms 6744 KB
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
int n,m,G[11][128][128],pos[128],f[128][128][128];
string s[200010];
char g[128];
bool vis[128];
long long ans;
int main()
{
	freopen("cubeword.in","r",stdin);
	freopen("cubeword.out","w",stdout);
	scanf("%d",&n);
	int x,y,z,i,j;
	for(i=1;i<=n;i++) {
		cin>>s[i];s[i+n]=s[i];
		reverse(s[i+n].begin(),s[i+n].end());
		for(j=0;j<s[i].size();j++) vis[s[i][j]]=1;
	}
	n*=2;
	sort(s+1,s+n+1);
	n=unique(s+1,s+n+1)-s-1;
	for(int i=0;i<128;i++) if(vis[i]) g[++m]=i,pos[i]=m;
	for(int i=1;i<=n;i++) G[s[i].size()][pos[s[i][0]]][pos[s[i][s[i].size()-1]]]++;
	for(int len=3;len<=10;len++) {
//		memset(f,0,sizeof(f));
			for(x=1;x<=m;x++) 
				for(y=1;y<=m;y++) 
					for(z=1;z<=m;z++) {
						f[x][y][z]=0;
						for(i=1;i<=m;i++) 
							f[x][y][z]=(f[x][y][z]+1ll*G[len][i][x]*G[len][i][y]%mod*G[len][i][z]%mod)%mod;
					}
		for(i=1;i<=m;i++) 
			for(x=1;x<=m;x++) 
				for(y=1;y<=m;y++) 
					for(z=1;z<=m;z++) 
						ans=(ans+1ll*f[i][x][y]*f[i][x][z]%mod*f[i][y][z]%mod*f[x][y][z]%mod)%mod;
	}
	printf("%lld",ans);
	return 0;
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:18:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for(j=0;j<s[i].size();j++) vis[s[i][j]]=1;
      |           ~^~~~~~~~~~~~
cubeword.cpp:18:41: warning: array subscript has type 'char' [-Wchar-subscripts]
   18 |   for(j=0;j<s[i].size();j++) vis[s[i][j]]=1;
      |                                         ^
cubeword.cpp:24:50: warning: array subscript has type 'char' [-Wchar-subscripts]
   24 |  for(int i=1;i<=n;i++) G[s[i].size()][pos[s[i][0]]][pos[s[i][s[i].size()-1]]]++;
      |                                                  ^
cubeword.cpp:24:76: warning: array subscript has type 'char' [-Wchar-subscripts]
   24 |  for(int i=1;i<=n;i++) G[s[i].size()][pos[s[i][0]]][pos[s[i][s[i].size()-1]]]++;
      |                                                                            ^
cubeword.cpp:11:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  freopen("cubeword.in","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cubeword.cpp:12:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  freopen("cubeword.out","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
cubeword.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -