답안 #898845

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898845 2024-01-05T07:53:25 Z arashMLG Cubeword (CEOI19_cubeword) C++17
0 / 100
501 ms 4864 KB
#include<bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse4")

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>   pll;

const int N = 5e5 + 23;
const int K = 26 + 26;
const ll mod = 998244353;
const ll inf = 1e18;

//#define F         first
#define S         second
#define pb        push_back
#define sz(x)     ((int)x.size())
#define all(x)    x.begin(),x.end()
#define lc        (v<<1)
#define rc        ((v<<1)|1)
#define F(x)      for(int x = 0; x < K; x++)
#define f(x,l)    for(int x=l; x < K; x++)
#define debug(x)  cout<<#x << " : " << x << endl;
#define int       ll

int dp[K][K][K];
vector<string> s[11];
int cnt[K][K];
vector<pii> vec;
int val[300];
int javab = 0;

void solve(int len) {
	F(i) F(j) {
		cnt[i][j] = 0;
		F(k) dp[i][j][k] = 0;
	}
	sort(all(s[len]));
	s[len].resize(unique(all(s[len])) - s[len].begin());
	for(string t : s[len]) {
		cnt[val[t[0]]][val[t.back()]] ++;
		string tp = t;
		reverse(all(tp));
		if(tp != t) {
			cnt[val[t.back()]][val[t[0]]] ++;
		}
	}
	F(i) F(a) F(b) F(c) {
		//debug(i);
		(dp[a][b][c] += (1LL*cnt[i][a]*cnt[i][b]%mod*cnt[i][c] %mod)) %= mod;
	}
	int ans=0;
	F(a) F(b) F(c) F(d) {
		(ans += (1LL*dp[a][b][c] *dp[a][b][d]%mod*dp[a][c][d]%mod*dp[b][c][d]%mod)) %= mod;
	}
	(javab += ans) %=mod;
}

int32_t main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	int x = 0;
	for(char c = 'a'; c<= 'z'; c++) {
		val[c] = x++;
	}
	for(char c = 'A'; c<= 'Z'; c++) {
		val[c] = x++;
	}
	for(char c = '0'; c <= '9'; c++) {
		val[c] = x ++;
	}
	int n; cin>>n;
	for(int i = 0 ;i < n ; i++){ 
		string t; cin>>t;
		if(t[0] > t.back()) reverse(all(t));
		s[sz(t)].pb(t);
	}
	for(int i = 3; i <= 10; i ++) solve(i);
	cout<<javab << '\n';
	return 0;
}

Compilation message

cubeword.cpp: In function 'void solve(ll)':
cubeword.cpp:43:15: warning: array subscript has type 'char' [-Wchar-subscripts]
   43 |   cnt[val[t[0]]][val[t.back()]] ++;
      |               ^
cubeword.cpp:43:28: warning: array subscript has type 'char' [-Wchar-subscripts]
   43 |   cnt[val[t[0]]][val[t.back()]] ++;
      |                      ~~~~~~^~
cubeword.cpp:47:18: warning: array subscript has type 'char' [-Wchar-subscripts]
   47 |    cnt[val[t.back()]][val[t[0]]] ++;
      |            ~~~~~~^~
cubeword.cpp:47:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   47 |    cnt[val[t.back()]][val[t[0]]] ++;
      |                               ^
cubeword.cpp: In function 'int32_t main()':
cubeword.cpp:65:7: warning: array subscript has type 'char' [-Wchar-subscripts]
   65 |   val[c] = x++;
      |       ^
cubeword.cpp:68:7: warning: array subscript has type 'char' [-Wchar-subscripts]
   68 |   val[c] = x++;
      |       ^
cubeword.cpp:71:7: warning: array subscript has type 'char' [-Wchar-subscripts]
   71 |   val[c] = x ++;
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 501 ms 4864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 501 ms 4864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 501 ms 4864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 501 ms 4864 KB Output isn't correct
2 Halted 0 ms 0 KB -