# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
556659 | 2022-05-03T13:37:56 Z | fatemetmhr | Cubeword (CEOI19_cubeword) | C++17 | 1100 ms | 24936 KB |
// ~~ Be name khoda ~~ // #include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2") 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1189 ms | 24936 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1189 ms | 24936 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1189 ms | 24936 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1189 ms | 24936 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |