Submission #556658

#TimeUsernameProblemLanguageResultExecution timeMemory
556658fatemetmhrCubeword (CEOI19_cubeword)C++17
0 / 100
1192 ms25680 KiB
// ~~ Be name khoda ~~ // #include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) x.begin(), x.end() #define fi first #define se second #define pb push_back const int al = 65; const int szz = 10; const int mod = 998244353; const int maxn5 = 1e5 + 10; set <string> av; int id[maxn5]; int have[al][al][al][szz]; int cnt[szz][al][al]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for(int i = 0; i < n; i++){ string s; cin >> s; av.insert(s); reverse(all(s)); av.insert(s); } int ind = 0; for(int i = 0; i < 26; i++){ id[i + 'a'] = ind++; id[i + 'A'] = ind++; if(i < 10) id[i + '0'] = ind++; } for(auto it = av.begin(); it != av.end(); it++){ string s = (*it); cnt[s.size() - 3][id[s[0]]][id[s[s.size() - 1]]]++; } for(int i = 0; i < ind; i++) for(int j = 0; j < ind; j++) for(int k = 0; k < ind; k++) for(int sz = 0; sz <= 8; sz++) for(int z = 0; z < ind; z++) have[i][j][k][sz] = (have[i][j][k][sz] + (ll(cnt[sz][i][z]) * cnt[sz][j][z] % mod) * cnt[sz][k][z]) % mod; ll ans = 0; for(int i = 0; i < ind; i++) for(int j = 0; j < ind; j++) for(int k = 0; k < ind; k++) for(int z = 0; z < ind; z++) for(int sz = 0; sz <= 8; sz++) ans = (ans + ((ll(have[i][j][k][sz]) * have[i][j][z][sz] % mod) * have[i][k][z][sz] % mod) * have[j][k][z][sz]) % mod; cout << ans << endl; }

Compilation message (stderr)

cubeword.cpp: In function 'int main()':
cubeword.cpp:48:34: warning: array subscript has type 'char' [-Wchar-subscripts]
   48 |         cnt[s.size() - 3][id[s[0]]][id[s[s.size() - 1]]]++;
      |                                  ^
cubeword.cpp:48:55: warning: array subscript has type 'char' [-Wchar-subscripts]
   48 |         cnt[s.size() - 3][id[s[0]]][id[s[s.size() - 1]]]++;
      |                                                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...