Submission #948526

#TimeUsernameProblemLanguageResultExecution timeMemory
948526GrandTiger1729Cubeword (CEOI19_cubeword)C++17
0 / 100
1104 ms21128 KiB
#include <bits/stdc++.h> using namespace std; namespace { const int N = 11, K = 128, MOD = 998244353; int cnt[N][K][K]{}; long long res[K][K][K]{}; const string charset = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; } int main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; vector<string> a(n); for (int i = 0; i < n; i++) { string s; cin >> s; string ss = s; reverse(ss.begin(), ss.end()); if (ss < s) { swap(s, ss); } a[i] = s; } sort(a.begin(), a.end()); a.resize(unique(a.begin(), a.end()) - a.begin()); n = a.size(); for (int i = 0; i < n; i++) { string s = a[i], ss = s; reverse(ss.begin(), ss.end()); if (s == ss) { cnt[s.size()][s[0]][ss[0]]++; } else { cnt[s.size()][s[0]][ss[0]]++; cnt[s.size()][ss[0]][s[0]]++; } } long long ans = 0; for (int t = 3; t < N; t++) { fill_n(&res[0][0][0], sizeof(res) / sizeof(long long), 0); for (int i : charset) { for (int j : charset) { for (int k : charset) { for (int l : charset) { (res[i][j][k] += 1ll * cnt[t][i][l] * cnt[t][j][l] * cnt[t][k][l]) %= MOD; } } } } for (int i : charset) { for (int j : charset) { for (int k : charset) { for (int l : charset) { (ans += res[i][j][k] * res[i][j][l] % MOD * res[i][k][l] % MOD * res[j][k][l]) %= MOD; } } } } } cout << ans << '\n'; return 0; }

Compilation message (stderr)

cubeword.cpp: In function 'int main()':
cubeword.cpp:38:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   38 |             cnt[s.size()][s[0]][ss[0]]++;
      |                               ^
cubeword.cpp:38:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   38 |             cnt[s.size()][s[0]][ss[0]]++;
      |                                      ^
cubeword.cpp:42:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   42 |             cnt[s.size()][s[0]][ss[0]]++;
      |                               ^
cubeword.cpp:42:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   42 |             cnt[s.size()][s[0]][ss[0]]++;
      |                                      ^
cubeword.cpp:43:32: warning: array subscript has type 'char' [-Wchar-subscripts]
   43 |             cnt[s.size()][ss[0]][s[0]]++;
      |                                ^
cubeword.cpp:43:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   43 |             cnt[s.size()][ss[0]][s[0]]++;
      |                                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...