# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
904762 | 2024-01-12T08:13:02 Z | andrei_iorgulescu | Cubeword (CEOI19_cubeword) | C++14 | 307 ms | 19916 KB |
#include <bits/stdc++.h> using namespace std; const int S = 32; const int modulo = 998244353; vector<string>cuv[15]; int cst[S][S]; int cost[S][S][S]; int toint(char c) { if (c >= 'a' and c <= 'p') return c - 'a'; else if (c >= 'A' and c <= 'P') return 16 + c - 'A'; } bool palint(string s) { for (int i = 1; i < s.size() - 1; i++) if (s[i] != s[s.size() - 1 - i]) return false; return true; } string inv(string s) { reverse(s.begin(),s.end()); return s; } map<string,bool>mp; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i = 1; i <= n; i++) { string s; cin >> s; cuv[s.size()].push_back(s); } int ans = 0; for (int l = 3; l <= 10; l++) { for (int i = 0; i < S; i++) for (int j = 0; j < S; j++) cst[i][j] = 0; for (int i = 0; i < S; i++) for (int j = 0; j < S; j++) for (int k = 0; k < S; k++) cost[i][j][k] = 0; for (auto it : cuv[l]) { if (mp[inv(it)] == true) continue; mp[it] = true; cst[toint(it[0])][toint(it[l - 1])]++; if (it[0] != it[l - 1]) cst[toint(it[l - 1])][toint(it[0])]++; else if (palint(it) == false) cst[toint(it[0])][toint(it[l - 1])]++; } for (int i = 0; i < S; i++) { for (int j = 0; j < S; j++) { for (int k = 0; k < S; k++) { for (int q = 0; q < S; q++) cost[i][j][k] = (0ll + cost[i][j][k] + 1ll * cst[i][q] * cst[j][q] * cst[k][q]) % modulo; } } } for (int A = 0; A < S; A++) { for (int B = 0; B < S; B++) { for (int C = 0; C < S; C++) { for (int D = 0; D < S; D++) { int adg = 1ll * cost[A][B][C] * cost[A][B][D] % modulo * cost[A][C][D] % modulo * cost[B][C][D] % modulo; ans = (ans + adg) % modulo; } } } } } cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 229 ms | 18256 KB | Output is correct |
2 | Correct | 187 ms | 18908 KB | Output is correct |
3 | Correct | 231 ms | 18988 KB | Output is correct |
4 | Correct | 277 ms | 19232 KB | Output is correct |
5 | Correct | 206 ms | 19036 KB | Output is correct |
6 | Correct | 208 ms | 19052 KB | Output is correct |
7 | Correct | 227 ms | 18988 KB | Output is correct |
8 | Correct | 240 ms | 18868 KB | Output is correct |
9 | Correct | 222 ms | 19028 KB | Output is correct |
10 | Correct | 225 ms | 19140 KB | Output is correct |
11 | Correct | 230 ms | 19104 KB | Output is correct |
12 | Correct | 243 ms | 18928 KB | Output is correct |
13 | Correct | 220 ms | 19084 KB | Output is correct |
14 | Correct | 244 ms | 19148 KB | Output is correct |
15 | Correct | 209 ms | 19020 KB | Output is correct |
16 | Correct | 249 ms | 18936 KB | Output is correct |
17 | Correct | 261 ms | 18940 KB | Output is correct |
18 | Correct | 218 ms | 18940 KB | Output is correct |
19 | Correct | 217 ms | 19084 KB | Output is correct |
20 | Correct | 233 ms | 18948 KB | Output is correct |
21 | Correct | 194 ms | 18904 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 229 ms | 18256 KB | Output is correct |
2 | Correct | 187 ms | 18908 KB | Output is correct |
3 | Correct | 231 ms | 18988 KB | Output is correct |
4 | Correct | 277 ms | 19232 KB | Output is correct |
5 | Correct | 206 ms | 19036 KB | Output is correct |
6 | Correct | 208 ms | 19052 KB | Output is correct |
7 | Correct | 227 ms | 18988 KB | Output is correct |
8 | Correct | 240 ms | 18868 KB | Output is correct |
9 | Correct | 222 ms | 19028 KB | Output is correct |
10 | Correct | 225 ms | 19140 KB | Output is correct |
11 | Correct | 230 ms | 19104 KB | Output is correct |
12 | Correct | 243 ms | 18928 KB | Output is correct |
13 | Correct | 220 ms | 19084 KB | Output is correct |
14 | Correct | 244 ms | 19148 KB | Output is correct |
15 | Correct | 209 ms | 19020 KB | Output is correct |
16 | Correct | 249 ms | 18936 KB | Output is correct |
17 | Correct | 261 ms | 18940 KB | Output is correct |
18 | Correct | 218 ms | 18940 KB | Output is correct |
19 | Correct | 217 ms | 19084 KB | Output is correct |
20 | Correct | 233 ms | 18948 KB | Output is correct |
21 | Correct | 194 ms | 18904 KB | Output is correct |
22 | Correct | 271 ms | 19652 KB | Output is correct |
23 | Correct | 249 ms | 19656 KB | Output is correct |
24 | Correct | 236 ms | 19548 KB | Output is correct |
25 | Correct | 235 ms | 19568 KB | Output is correct |
26 | Correct | 245 ms | 19472 KB | Output is correct |
27 | Correct | 224 ms | 19564 KB | Output is correct |
28 | Correct | 274 ms | 19556 KB | Output is correct |
29 | Correct | 225 ms | 19672 KB | Output is correct |
30 | Correct | 261 ms | 19496 KB | Output is correct |
31 | Correct | 255 ms | 19592 KB | Output is correct |
32 | Correct | 237 ms | 19596 KB | Output is correct |
33 | Correct | 218 ms | 19432 KB | Output is correct |
34 | Correct | 233 ms | 19464 KB | Output is correct |
35 | Correct | 263 ms | 19692 KB | Output is correct |
36 | Correct | 291 ms | 19420 KB | Output is correct |
37 | Correct | 240 ms | 19644 KB | Output is correct |
38 | Correct | 268 ms | 19504 KB | Output is correct |
39 | Correct | 232 ms | 19648 KB | Output is correct |
40 | Correct | 196 ms | 19628 KB | Output is correct |
41 | Correct | 305 ms | 19516 KB | Output is correct |
42 | Correct | 242 ms | 19632 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 229 ms | 18256 KB | Output is correct |
2 | Correct | 187 ms | 18908 KB | Output is correct |
3 | Correct | 231 ms | 18988 KB | Output is correct |
4 | Correct | 277 ms | 19232 KB | Output is correct |
5 | Correct | 206 ms | 19036 KB | Output is correct |
6 | Correct | 208 ms | 19052 KB | Output is correct |
7 | Correct | 227 ms | 18988 KB | Output is correct |
8 | Correct | 240 ms | 18868 KB | Output is correct |
9 | Correct | 222 ms | 19028 KB | Output is correct |
10 | Correct | 225 ms | 19140 KB | Output is correct |
11 | Correct | 230 ms | 19104 KB | Output is correct |
12 | Correct | 243 ms | 18928 KB | Output is correct |
13 | Correct | 220 ms | 19084 KB | Output is correct |
14 | Correct | 244 ms | 19148 KB | Output is correct |
15 | Correct | 209 ms | 19020 KB | Output is correct |
16 | Correct | 249 ms | 18936 KB | Output is correct |
17 | Correct | 261 ms | 18940 KB | Output is correct |
18 | Correct | 218 ms | 18940 KB | Output is correct |
19 | Correct | 217 ms | 19084 KB | Output is correct |
20 | Correct | 233 ms | 18948 KB | Output is correct |
21 | Correct | 194 ms | 18904 KB | Output is correct |
22 | Correct | 271 ms | 19652 KB | Output is correct |
23 | Correct | 249 ms | 19656 KB | Output is correct |
24 | Correct | 236 ms | 19548 KB | Output is correct |
25 | Correct | 235 ms | 19568 KB | Output is correct |
26 | Correct | 245 ms | 19472 KB | Output is correct |
27 | Correct | 224 ms | 19564 KB | Output is correct |
28 | Correct | 274 ms | 19556 KB | Output is correct |
29 | Correct | 225 ms | 19672 KB | Output is correct |
30 | Correct | 261 ms | 19496 KB | Output is correct |
31 | Correct | 255 ms | 19592 KB | Output is correct |
32 | Correct | 237 ms | 19596 KB | Output is correct |
33 | Correct | 218 ms | 19432 KB | Output is correct |
34 | Correct | 233 ms | 19464 KB | Output is correct |
35 | Correct | 263 ms | 19692 KB | Output is correct |
36 | Correct | 291 ms | 19420 KB | Output is correct |
37 | Correct | 240 ms | 19644 KB | Output is correct |
38 | Correct | 268 ms | 19504 KB | Output is correct |
39 | Correct | 232 ms | 19648 KB | Output is correct |
40 | Correct | 196 ms | 19628 KB | Output is correct |
41 | Correct | 305 ms | 19516 KB | Output is correct |
42 | Correct | 242 ms | 19632 KB | Output is correct |
43 | Correct | 210 ms | 19916 KB | Output is correct |
44 | Correct | 307 ms | 19888 KB | Output is correct |
45 | Correct | 208 ms | 19816 KB | Output is correct |
46 | Correct | 213 ms | 19756 KB | Output is correct |
47 | Correct | 248 ms | 19808 KB | Output is correct |
48 | Correct | 250 ms | 19688 KB | Output is correct |
49 | Correct | 220 ms | 19676 KB | Output is correct |
50 | Correct | 229 ms | 19852 KB | Output is correct |
51 | Correct | 188 ms | 19672 KB | Output is correct |
52 | Correct | 189 ms | 19760 KB | Output is correct |
53 | Correct | 230 ms | 19712 KB | Output is correct |
54 | Correct | 220 ms | 19880 KB | Output is correct |
55 | Correct | 232 ms | 19596 KB | Output is correct |
56 | Correct | 266 ms | 19888 KB | Output is correct |
57 | Correct | 179 ms | 19748 KB | Output is correct |
58 | Correct | 217 ms | 19608 KB | Output is correct |
59 | Correct | 202 ms | 19836 KB | Output is correct |
60 | Correct | 224 ms | 19748 KB | Output is correct |
61 | Correct | 235 ms | 19612 KB | Output is correct |
62 | Correct | 228 ms | 19692 KB | Output is correct |
63 | Correct | 234 ms | 19788 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 229 ms | 18256 KB | Output is correct |
2 | Correct | 187 ms | 18908 KB | Output is correct |
3 | Correct | 231 ms | 18988 KB | Output is correct |
4 | Correct | 277 ms | 19232 KB | Output is correct |
5 | Correct | 206 ms | 19036 KB | Output is correct |
6 | Correct | 208 ms | 19052 KB | Output is correct |
7 | Correct | 227 ms | 18988 KB | Output is correct |
8 | Correct | 240 ms | 18868 KB | Output is correct |
9 | Correct | 222 ms | 19028 KB | Output is correct |
10 | Correct | 225 ms | 19140 KB | Output is correct |
11 | Correct | 230 ms | 19104 KB | Output is correct |
12 | Correct | 243 ms | 18928 KB | Output is correct |
13 | Correct | 220 ms | 19084 KB | Output is correct |
14 | Correct | 244 ms | 19148 KB | Output is correct |
15 | Correct | 209 ms | 19020 KB | Output is correct |
16 | Correct | 249 ms | 18936 KB | Output is correct |
17 | Correct | 261 ms | 18940 KB | Output is correct |
18 | Correct | 218 ms | 18940 KB | Output is correct |
19 | Correct | 217 ms | 19084 KB | Output is correct |
20 | Correct | 233 ms | 18948 KB | Output is correct |
21 | Correct | 194 ms | 18904 KB | Output is correct |
22 | Correct | 271 ms | 19652 KB | Output is correct |
23 | Correct | 249 ms | 19656 KB | Output is correct |
24 | Correct | 236 ms | 19548 KB | Output is correct |
25 | Correct | 235 ms | 19568 KB | Output is correct |
26 | Correct | 245 ms | 19472 KB | Output is correct |
27 | Correct | 224 ms | 19564 KB | Output is correct |
28 | Correct | 274 ms | 19556 KB | Output is correct |
29 | Correct | 225 ms | 19672 KB | Output is correct |
30 | Correct | 261 ms | 19496 KB | Output is correct |
31 | Correct | 255 ms | 19592 KB | Output is correct |
32 | Correct | 237 ms | 19596 KB | Output is correct |
33 | Correct | 218 ms | 19432 KB | Output is correct |
34 | Correct | 233 ms | 19464 KB | Output is correct |
35 | Correct | 263 ms | 19692 KB | Output is correct |
36 | Correct | 291 ms | 19420 KB | Output is correct |
37 | Correct | 240 ms | 19644 KB | Output is correct |
38 | Correct | 268 ms | 19504 KB | Output is correct |
39 | Correct | 232 ms | 19648 KB | Output is correct |
40 | Correct | 196 ms | 19628 KB | Output is correct |
41 | Correct | 305 ms | 19516 KB | Output is correct |
42 | Correct | 242 ms | 19632 KB | Output is correct |
43 | Correct | 210 ms | 19916 KB | Output is correct |
44 | Correct | 307 ms | 19888 KB | Output is correct |
45 | Correct | 208 ms | 19816 KB | Output is correct |
46 | Correct | 213 ms | 19756 KB | Output is correct |
47 | Correct | 248 ms | 19808 KB | Output is correct |
48 | Correct | 250 ms | 19688 KB | Output is correct |
49 | Correct | 220 ms | 19676 KB | Output is correct |
50 | Correct | 229 ms | 19852 KB | Output is correct |
51 | Correct | 188 ms | 19672 KB | Output is correct |
52 | Correct | 189 ms | 19760 KB | Output is correct |
53 | Correct | 230 ms | 19712 KB | Output is correct |
54 | Correct | 220 ms | 19880 KB | Output is correct |
55 | Correct | 232 ms | 19596 KB | Output is correct |
56 | Correct | 266 ms | 19888 KB | Output is correct |
57 | Correct | 179 ms | 19748 KB | Output is correct |
58 | Correct | 217 ms | 19608 KB | Output is correct |
59 | Correct | 202 ms | 19836 KB | Output is correct |
60 | Correct | 224 ms | 19748 KB | Output is correct |
61 | Correct | 235 ms | 19612 KB | Output is correct |
62 | Correct | 228 ms | 19692 KB | Output is correct |
63 | Correct | 234 ms | 19788 KB | Output is correct |
64 | Runtime error | 31 ms | 11692 KB | Execution killed with signal 11 |
65 | Halted | 0 ms | 0 KB | - |