# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
934403 |
2024-02-27T09:42:40 Z |
sysia |
Cubeword (CEOI19_cubeword) |
C++17 |
|
1070 ms |
19616 KB |
//Sylwia Sapkowska
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << "'" << x << "'";}
void __print(const char *x) {cerr << '"' << x << '"';}
void __print(const string &x) {cerr << '"' << x << '"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long
typedef pair<int, int> T;
const int oo = 1e18, oo2 = 1e9+7, K = 30;
const int mod = 998244353;
const int A = 11, mx = 62;
int mul(int a, int b){
return (a*b)%mod;
}
void add(int &a, int b){
a += b;
if (a >= mod) a-= mod;
}
void solve(){
int n; cin >> n;
vector cnt(A, vector<vector<int>>(mx, vector<int>(mx)));
set<string>a;
char cc = 'A';
vector<int>ord(130);
int ptr = 0;
for (char c = 'a'; c <= 'z'; c++) {
ord[c] = ptr++;
}
for (char c = 'A'; c <= 'Z'; c++) {
ord[c] = ptr++;
}
for (char c = '0'; c <= '9'; c++){
ord[c] = ptr++;
}
for (int i = 0; i<n; i++){
string s; cin >> s;
int l = (int)s.size();
if (a.find(s) == a.end()){
a.insert(s);
cnt[l][ord[s[0]]][ord[s.back()]]++;
}
auto t = s;
reverse(t.begin(), t.end());
if (a.find(t) == a.end()) {
cnt[l][ord[s.back()]][ord[s[0]]]++;
a.insert(t);
}
}
int ans = 0;
vector zlicz(mx, vector<vector<int>>(mx, vector<int>(mx)));
for (int rep = 3; rep < A; rep++){
debug(rep);
for (int a = 0; a < mx; a++){
for (int b = 0; b < mx; b++){
for (int c = 0; c < mx; c++){
zlicz[a][b][c] = 0;
}
}
}
int sum = 0;
for (int beg = 0; beg < mx; beg++){
for (int a = 0; a < mx; a++){
for (int b = 0; b < mx; b++){
for (int c = 0; c < mx; c++){
add(zlicz[a][b][c], mul(cnt[rep][beg][a], mul(cnt[rep][beg][b], cnt[rep][beg][c])));
}
}
}
}
for (int a = 0; a < mx; a++){
for (int b = 0; b < mx; b++){
for (int c = 0; c < mx; c++){
for (int d = 0; d < mx; d++){
add(ans, mul(mul(zlicz[a][b][c], zlicz[a][c][d]), mul(zlicz[b][c][d], zlicz[a][b][d])));
}
}
}
}
}
cout << ans << "\n";
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
Compilation message
cubeword.cpp: In function 'void solve()':
cubeword.cpp:83:13: warning: unused variable 'sum' [-Wunused-variable]
83 | int sum = 0;
| ^~~
cubeword.cpp:46:10: warning: unused variable 'cc' [-Wunused-variable]
46 | char cc = 'A';
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
958 ms |
17332 KB |
Output is correct |
2 |
Correct |
1004 ms |
17316 KB |
Output is correct |
3 |
Correct |
966 ms |
17488 KB |
Output is correct |
4 |
Correct |
971 ms |
17320 KB |
Output is correct |
5 |
Correct |
973 ms |
17328 KB |
Output is correct |
6 |
Correct |
972 ms |
17324 KB |
Output is correct |
7 |
Correct |
1032 ms |
17336 KB |
Output is correct |
8 |
Correct |
1018 ms |
17332 KB |
Output is correct |
9 |
Correct |
959 ms |
17448 KB |
Output is correct |
10 |
Correct |
961 ms |
17332 KB |
Output is correct |
11 |
Correct |
956 ms |
17492 KB |
Output is correct |
12 |
Correct |
978 ms |
17316 KB |
Output is correct |
13 |
Correct |
960 ms |
17492 KB |
Output is correct |
14 |
Correct |
995 ms |
17232 KB |
Output is correct |
15 |
Correct |
959 ms |
17256 KB |
Output is correct |
16 |
Correct |
994 ms |
17320 KB |
Output is correct |
17 |
Correct |
994 ms |
17328 KB |
Output is correct |
18 |
Correct |
1024 ms |
17316 KB |
Output is correct |
19 |
Correct |
1000 ms |
17232 KB |
Output is correct |
20 |
Correct |
974 ms |
17492 KB |
Output is correct |
21 |
Correct |
970 ms |
17328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
958 ms |
17332 KB |
Output is correct |
2 |
Correct |
1004 ms |
17316 KB |
Output is correct |
3 |
Correct |
966 ms |
17488 KB |
Output is correct |
4 |
Correct |
971 ms |
17320 KB |
Output is correct |
5 |
Correct |
973 ms |
17328 KB |
Output is correct |
6 |
Correct |
972 ms |
17324 KB |
Output is correct |
7 |
Correct |
1032 ms |
17336 KB |
Output is correct |
8 |
Correct |
1018 ms |
17332 KB |
Output is correct |
9 |
Correct |
959 ms |
17448 KB |
Output is correct |
10 |
Correct |
961 ms |
17332 KB |
Output is correct |
11 |
Correct |
956 ms |
17492 KB |
Output is correct |
12 |
Correct |
978 ms |
17316 KB |
Output is correct |
13 |
Correct |
960 ms |
17492 KB |
Output is correct |
14 |
Correct |
995 ms |
17232 KB |
Output is correct |
15 |
Correct |
959 ms |
17256 KB |
Output is correct |
16 |
Correct |
994 ms |
17320 KB |
Output is correct |
17 |
Correct |
994 ms |
17328 KB |
Output is correct |
18 |
Correct |
1024 ms |
17316 KB |
Output is correct |
19 |
Correct |
1000 ms |
17232 KB |
Output is correct |
20 |
Correct |
974 ms |
17492 KB |
Output is correct |
21 |
Correct |
970 ms |
17328 KB |
Output is correct |
22 |
Correct |
1018 ms |
18004 KB |
Output is correct |
23 |
Correct |
991 ms |
18000 KB |
Output is correct |
24 |
Correct |
1002 ms |
18000 KB |
Output is correct |
25 |
Correct |
1010 ms |
17984 KB |
Output is correct |
26 |
Correct |
983 ms |
18052 KB |
Output is correct |
27 |
Correct |
966 ms |
18004 KB |
Output is correct |
28 |
Correct |
994 ms |
17988 KB |
Output is correct |
29 |
Correct |
990 ms |
17956 KB |
Output is correct |
30 |
Correct |
966 ms |
17984 KB |
Output is correct |
31 |
Correct |
967 ms |
17988 KB |
Output is correct |
32 |
Correct |
1004 ms |
18004 KB |
Output is correct |
33 |
Correct |
1018 ms |
17972 KB |
Output is correct |
34 |
Correct |
999 ms |
17748 KB |
Output is correct |
35 |
Correct |
1000 ms |
17984 KB |
Output is correct |
36 |
Correct |
966 ms |
17760 KB |
Output is correct |
37 |
Correct |
982 ms |
17988 KB |
Output is correct |
38 |
Correct |
976 ms |
17988 KB |
Output is correct |
39 |
Correct |
967 ms |
17988 KB |
Output is correct |
40 |
Correct |
969 ms |
17980 KB |
Output is correct |
41 |
Correct |
965 ms |
18000 KB |
Output is correct |
42 |
Correct |
1070 ms |
17844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
958 ms |
17332 KB |
Output is correct |
2 |
Correct |
1004 ms |
17316 KB |
Output is correct |
3 |
Correct |
966 ms |
17488 KB |
Output is correct |
4 |
Correct |
971 ms |
17320 KB |
Output is correct |
5 |
Correct |
973 ms |
17328 KB |
Output is correct |
6 |
Correct |
972 ms |
17324 KB |
Output is correct |
7 |
Correct |
1032 ms |
17336 KB |
Output is correct |
8 |
Correct |
1018 ms |
17332 KB |
Output is correct |
9 |
Correct |
959 ms |
17448 KB |
Output is correct |
10 |
Correct |
961 ms |
17332 KB |
Output is correct |
11 |
Correct |
956 ms |
17492 KB |
Output is correct |
12 |
Correct |
978 ms |
17316 KB |
Output is correct |
13 |
Correct |
960 ms |
17492 KB |
Output is correct |
14 |
Correct |
995 ms |
17232 KB |
Output is correct |
15 |
Correct |
959 ms |
17256 KB |
Output is correct |
16 |
Correct |
994 ms |
17320 KB |
Output is correct |
17 |
Correct |
994 ms |
17328 KB |
Output is correct |
18 |
Correct |
1024 ms |
17316 KB |
Output is correct |
19 |
Correct |
1000 ms |
17232 KB |
Output is correct |
20 |
Correct |
974 ms |
17492 KB |
Output is correct |
21 |
Correct |
970 ms |
17328 KB |
Output is correct |
22 |
Correct |
1018 ms |
18004 KB |
Output is correct |
23 |
Correct |
991 ms |
18000 KB |
Output is correct |
24 |
Correct |
1002 ms |
18000 KB |
Output is correct |
25 |
Correct |
1010 ms |
17984 KB |
Output is correct |
26 |
Correct |
983 ms |
18052 KB |
Output is correct |
27 |
Correct |
966 ms |
18004 KB |
Output is correct |
28 |
Correct |
994 ms |
17988 KB |
Output is correct |
29 |
Correct |
990 ms |
17956 KB |
Output is correct |
30 |
Correct |
966 ms |
17984 KB |
Output is correct |
31 |
Correct |
967 ms |
17988 KB |
Output is correct |
32 |
Correct |
1004 ms |
18004 KB |
Output is correct |
33 |
Correct |
1018 ms |
17972 KB |
Output is correct |
34 |
Correct |
999 ms |
17748 KB |
Output is correct |
35 |
Correct |
1000 ms |
17984 KB |
Output is correct |
36 |
Correct |
966 ms |
17760 KB |
Output is correct |
37 |
Correct |
982 ms |
17988 KB |
Output is correct |
38 |
Correct |
976 ms |
17988 KB |
Output is correct |
39 |
Correct |
967 ms |
17988 KB |
Output is correct |
40 |
Correct |
969 ms |
17980 KB |
Output is correct |
41 |
Correct |
965 ms |
18000 KB |
Output is correct |
42 |
Correct |
1070 ms |
17844 KB |
Output is correct |
43 |
Correct |
1022 ms |
18424 KB |
Output is correct |
44 |
Correct |
986 ms |
18256 KB |
Output is correct |
45 |
Correct |
974 ms |
18192 KB |
Output is correct |
46 |
Correct |
975 ms |
18192 KB |
Output is correct |
47 |
Correct |
974 ms |
18304 KB |
Output is correct |
48 |
Correct |
991 ms |
18200 KB |
Output is correct |
49 |
Correct |
976 ms |
18260 KB |
Output is correct |
50 |
Correct |
983 ms |
18200 KB |
Output is correct |
51 |
Correct |
1010 ms |
18332 KB |
Output is correct |
52 |
Correct |
983 ms |
18188 KB |
Output is correct |
53 |
Correct |
984 ms |
18256 KB |
Output is correct |
54 |
Correct |
978 ms |
18256 KB |
Output is correct |
55 |
Correct |
968 ms |
18204 KB |
Output is correct |
56 |
Correct |
1014 ms |
18208 KB |
Output is correct |
57 |
Correct |
970 ms |
18184 KB |
Output is correct |
58 |
Correct |
975 ms |
18200 KB |
Output is correct |
59 |
Correct |
992 ms |
18196 KB |
Output is correct |
60 |
Correct |
961 ms |
18188 KB |
Output is correct |
61 |
Correct |
972 ms |
18196 KB |
Output is correct |
62 |
Correct |
972 ms |
18196 KB |
Output is correct |
63 |
Correct |
1014 ms |
18192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
958 ms |
17332 KB |
Output is correct |
2 |
Correct |
1004 ms |
17316 KB |
Output is correct |
3 |
Correct |
966 ms |
17488 KB |
Output is correct |
4 |
Correct |
971 ms |
17320 KB |
Output is correct |
5 |
Correct |
973 ms |
17328 KB |
Output is correct |
6 |
Correct |
972 ms |
17324 KB |
Output is correct |
7 |
Correct |
1032 ms |
17336 KB |
Output is correct |
8 |
Correct |
1018 ms |
17332 KB |
Output is correct |
9 |
Correct |
959 ms |
17448 KB |
Output is correct |
10 |
Correct |
961 ms |
17332 KB |
Output is correct |
11 |
Correct |
956 ms |
17492 KB |
Output is correct |
12 |
Correct |
978 ms |
17316 KB |
Output is correct |
13 |
Correct |
960 ms |
17492 KB |
Output is correct |
14 |
Correct |
995 ms |
17232 KB |
Output is correct |
15 |
Correct |
959 ms |
17256 KB |
Output is correct |
16 |
Correct |
994 ms |
17320 KB |
Output is correct |
17 |
Correct |
994 ms |
17328 KB |
Output is correct |
18 |
Correct |
1024 ms |
17316 KB |
Output is correct |
19 |
Correct |
1000 ms |
17232 KB |
Output is correct |
20 |
Correct |
974 ms |
17492 KB |
Output is correct |
21 |
Correct |
970 ms |
17328 KB |
Output is correct |
22 |
Correct |
1018 ms |
18004 KB |
Output is correct |
23 |
Correct |
991 ms |
18000 KB |
Output is correct |
24 |
Correct |
1002 ms |
18000 KB |
Output is correct |
25 |
Correct |
1010 ms |
17984 KB |
Output is correct |
26 |
Correct |
983 ms |
18052 KB |
Output is correct |
27 |
Correct |
966 ms |
18004 KB |
Output is correct |
28 |
Correct |
994 ms |
17988 KB |
Output is correct |
29 |
Correct |
990 ms |
17956 KB |
Output is correct |
30 |
Correct |
966 ms |
17984 KB |
Output is correct |
31 |
Correct |
967 ms |
17988 KB |
Output is correct |
32 |
Correct |
1004 ms |
18004 KB |
Output is correct |
33 |
Correct |
1018 ms |
17972 KB |
Output is correct |
34 |
Correct |
999 ms |
17748 KB |
Output is correct |
35 |
Correct |
1000 ms |
17984 KB |
Output is correct |
36 |
Correct |
966 ms |
17760 KB |
Output is correct |
37 |
Correct |
982 ms |
17988 KB |
Output is correct |
38 |
Correct |
976 ms |
17988 KB |
Output is correct |
39 |
Correct |
967 ms |
17988 KB |
Output is correct |
40 |
Correct |
969 ms |
17980 KB |
Output is correct |
41 |
Correct |
965 ms |
18000 KB |
Output is correct |
42 |
Correct |
1070 ms |
17844 KB |
Output is correct |
43 |
Correct |
1022 ms |
18424 KB |
Output is correct |
44 |
Correct |
986 ms |
18256 KB |
Output is correct |
45 |
Correct |
974 ms |
18192 KB |
Output is correct |
46 |
Correct |
975 ms |
18192 KB |
Output is correct |
47 |
Correct |
974 ms |
18304 KB |
Output is correct |
48 |
Correct |
991 ms |
18200 KB |
Output is correct |
49 |
Correct |
976 ms |
18260 KB |
Output is correct |
50 |
Correct |
983 ms |
18200 KB |
Output is correct |
51 |
Correct |
1010 ms |
18332 KB |
Output is correct |
52 |
Correct |
983 ms |
18188 KB |
Output is correct |
53 |
Correct |
984 ms |
18256 KB |
Output is correct |
54 |
Correct |
978 ms |
18256 KB |
Output is correct |
55 |
Correct |
968 ms |
18204 KB |
Output is correct |
56 |
Correct |
1014 ms |
18208 KB |
Output is correct |
57 |
Correct |
970 ms |
18184 KB |
Output is correct |
58 |
Correct |
975 ms |
18200 KB |
Output is correct |
59 |
Correct |
992 ms |
18196 KB |
Output is correct |
60 |
Correct |
961 ms |
18188 KB |
Output is correct |
61 |
Correct |
972 ms |
18196 KB |
Output is correct |
62 |
Correct |
972 ms |
18196 KB |
Output is correct |
63 |
Correct |
1014 ms |
18192 KB |
Output is correct |
64 |
Correct |
995 ms |
19152 KB |
Output is correct |
65 |
Correct |
990 ms |
19176 KB |
Output is correct |
66 |
Correct |
966 ms |
19176 KB |
Output is correct |
67 |
Correct |
964 ms |
19280 KB |
Output is correct |
68 |
Correct |
995 ms |
19168 KB |
Output is correct |
69 |
Correct |
987 ms |
19284 KB |
Output is correct |
70 |
Correct |
976 ms |
19280 KB |
Output is correct |
71 |
Correct |
975 ms |
19164 KB |
Output is correct |
72 |
Correct |
975 ms |
19616 KB |
Output is correct |
73 |
Correct |
968 ms |
19168 KB |
Output is correct |
74 |
Correct |
974 ms |
19280 KB |
Output is correct |
75 |
Correct |
968 ms |
19396 KB |
Output is correct |
76 |
Correct |
965 ms |
19172 KB |
Output is correct |
77 |
Correct |
986 ms |
19148 KB |
Output is correct |
78 |
Correct |
964 ms |
19280 KB |
Output is correct |
79 |
Correct |
971 ms |
19164 KB |
Output is correct |
80 |
Correct |
984 ms |
19256 KB |
Output is correct |
81 |
Correct |
972 ms |
19268 KB |
Output is correct |
82 |
Correct |
968 ms |
19288 KB |
Output is correct |
83 |
Correct |
972 ms |
19280 KB |
Output is correct |
84 |
Correct |
997 ms |
19172 KB |
Output is correct |