Submission #546607

# Submission time Handle Problem Language Result Execution time Memory
546607 2022-04-07T21:19:30 Z LucaDantas Cubeword (CEOI19_cubeword) C++17
50 / 100
268 ms 15692 KB
#pragma GCC optimize("Ofast") 
#pragma GCC optimize("unroll-loops") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") 
#include <bits/stdc++.h>
using namespace std;

constexpr int maxn = 16, mod = 998244353; // subtasks 1-2

int ans;

int edge[11][maxn][maxn];

int value_triad[11][maxn][maxn][maxn];

int id(char c) { return c-'a'; } // subtaks 1-2

set<string> mark;

void add(int& a, int b) { a += b; if(a >= mod) a -= mod; }

int D[11][maxn][maxn][maxn];

int main() {
    int n; cin >> n;
    string s;
    for(int i = 0; i < n; i++) {
        cin >> s;
        for(int rep = 0; rep < 2; rep++, reverse(s.begin(), s.end())) if(!mark.count(s)) {
            edge[s.size()][id(s[0])][id(s.back())]++;
            mark.insert(s);
        }
    }


    for(int sz = 3; sz <= 10; sz++)
        for(int a = 0; a < maxn; a++) for(int b = 0; b < maxn; b++) for(int c = 0; c < maxn; c++)
            for(int x = 0; x < maxn; x++)
                add(D[sz][a][b][c], 1ll * edge[sz][x][a] * edge[sz][x][b] % mod * edge[sz][x][c] % mod);

    for(int sz = 3; sz <= 10; sz++) {
        for(int a = 0; a < maxn; a++) for(int b = 0; b < maxn; b++) for(int c = 0; c < maxn; c++) for(int d = 0; d < maxn; d++)
        add(ans, 1ll * D[sz][a][b][c] * D[sz][a][b][d] % mod * D[sz][a][c][d] % mod * D[sz][b][c][d] % mod);
    }

    printf("%d\n", ans);
}
# Verdict Execution time Memory Grader output
1 Correct 191 ms 14828 KB Output is correct
2 Correct 211 ms 14908 KB Output is correct
3 Correct 233 ms 14972 KB Output is correct
4 Correct 189 ms 14884 KB Output is correct
5 Correct 193 ms 14916 KB Output is correct
6 Correct 200 ms 14912 KB Output is correct
7 Correct 228 ms 14912 KB Output is correct
8 Correct 206 ms 14920 KB Output is correct
9 Correct 209 ms 14972 KB Output is correct
10 Correct 208 ms 14860 KB Output is correct
11 Correct 209 ms 14844 KB Output is correct
12 Correct 197 ms 14884 KB Output is correct
13 Correct 213 ms 14928 KB Output is correct
14 Correct 231 ms 14912 KB Output is correct
15 Correct 204 ms 14900 KB Output is correct
16 Correct 243 ms 15004 KB Output is correct
17 Correct 227 ms 14876 KB Output is correct
18 Correct 228 ms 14792 KB Output is correct
19 Correct 203 ms 14896 KB Output is correct
20 Correct 208 ms 14796 KB Output is correct
21 Correct 204 ms 14904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 191 ms 14828 KB Output is correct
2 Correct 211 ms 14908 KB Output is correct
3 Correct 233 ms 14972 KB Output is correct
4 Correct 189 ms 14884 KB Output is correct
5 Correct 193 ms 14916 KB Output is correct
6 Correct 200 ms 14912 KB Output is correct
7 Correct 228 ms 14912 KB Output is correct
8 Correct 206 ms 14920 KB Output is correct
9 Correct 209 ms 14972 KB Output is correct
10 Correct 208 ms 14860 KB Output is correct
11 Correct 209 ms 14844 KB Output is correct
12 Correct 197 ms 14884 KB Output is correct
13 Correct 213 ms 14928 KB Output is correct
14 Correct 231 ms 14912 KB Output is correct
15 Correct 204 ms 14900 KB Output is correct
16 Correct 243 ms 15004 KB Output is correct
17 Correct 227 ms 14876 KB Output is correct
18 Correct 228 ms 14792 KB Output is correct
19 Correct 203 ms 14896 KB Output is correct
20 Correct 208 ms 14796 KB Output is correct
21 Correct 204 ms 14904 KB Output is correct
22 Correct 205 ms 15472 KB Output is correct
23 Correct 238 ms 15560 KB Output is correct
24 Correct 195 ms 15480 KB Output is correct
25 Correct 206 ms 15564 KB Output is correct
26 Correct 206 ms 15496 KB Output is correct
27 Correct 206 ms 15496 KB Output is correct
28 Correct 210 ms 15568 KB Output is correct
29 Correct 215 ms 15640 KB Output is correct
30 Correct 220 ms 15560 KB Output is correct
31 Correct 185 ms 15440 KB Output is correct
32 Correct 222 ms 15520 KB Output is correct
33 Correct 220 ms 15528 KB Output is correct
34 Correct 237 ms 15572 KB Output is correct
35 Correct 223 ms 15460 KB Output is correct
36 Correct 215 ms 15544 KB Output is correct
37 Correct 249 ms 15524 KB Output is correct
38 Correct 211 ms 15572 KB Output is correct
39 Correct 224 ms 15488 KB Output is correct
40 Correct 268 ms 15480 KB Output is correct
41 Correct 207 ms 15564 KB Output is correct
42 Correct 209 ms 15584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 191 ms 14828 KB Output is correct
2 Correct 211 ms 14908 KB Output is correct
3 Correct 233 ms 14972 KB Output is correct
4 Correct 189 ms 14884 KB Output is correct
5 Correct 193 ms 14916 KB Output is correct
6 Correct 200 ms 14912 KB Output is correct
7 Correct 228 ms 14912 KB Output is correct
8 Correct 206 ms 14920 KB Output is correct
9 Correct 209 ms 14972 KB Output is correct
10 Correct 208 ms 14860 KB Output is correct
11 Correct 209 ms 14844 KB Output is correct
12 Correct 197 ms 14884 KB Output is correct
13 Correct 213 ms 14928 KB Output is correct
14 Correct 231 ms 14912 KB Output is correct
15 Correct 204 ms 14900 KB Output is correct
16 Correct 243 ms 15004 KB Output is correct
17 Correct 227 ms 14876 KB Output is correct
18 Correct 228 ms 14792 KB Output is correct
19 Correct 203 ms 14896 KB Output is correct
20 Correct 208 ms 14796 KB Output is correct
21 Correct 204 ms 14904 KB Output is correct
22 Correct 205 ms 15472 KB Output is correct
23 Correct 238 ms 15560 KB Output is correct
24 Correct 195 ms 15480 KB Output is correct
25 Correct 206 ms 15564 KB Output is correct
26 Correct 206 ms 15496 KB Output is correct
27 Correct 206 ms 15496 KB Output is correct
28 Correct 210 ms 15568 KB Output is correct
29 Correct 215 ms 15640 KB Output is correct
30 Correct 220 ms 15560 KB Output is correct
31 Correct 185 ms 15440 KB Output is correct
32 Correct 222 ms 15520 KB Output is correct
33 Correct 220 ms 15528 KB Output is correct
34 Correct 237 ms 15572 KB Output is correct
35 Correct 223 ms 15460 KB Output is correct
36 Correct 215 ms 15544 KB Output is correct
37 Correct 249 ms 15524 KB Output is correct
38 Correct 211 ms 15572 KB Output is correct
39 Correct 224 ms 15488 KB Output is correct
40 Correct 268 ms 15480 KB Output is correct
41 Correct 207 ms 15564 KB Output is correct
42 Correct 209 ms 15584 KB Output is correct
43 Incorrect 260 ms 15692 KB Output isn't correct
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 191 ms 14828 KB Output is correct
2 Correct 211 ms 14908 KB Output is correct
3 Correct 233 ms 14972 KB Output is correct
4 Correct 189 ms 14884 KB Output is correct
5 Correct 193 ms 14916 KB Output is correct
6 Correct 200 ms 14912 KB Output is correct
7 Correct 228 ms 14912 KB Output is correct
8 Correct 206 ms 14920 KB Output is correct
9 Correct 209 ms 14972 KB Output is correct
10 Correct 208 ms 14860 KB Output is correct
11 Correct 209 ms 14844 KB Output is correct
12 Correct 197 ms 14884 KB Output is correct
13 Correct 213 ms 14928 KB Output is correct
14 Correct 231 ms 14912 KB Output is correct
15 Correct 204 ms 14900 KB Output is correct
16 Correct 243 ms 15004 KB Output is correct
17 Correct 227 ms 14876 KB Output is correct
18 Correct 228 ms 14792 KB Output is correct
19 Correct 203 ms 14896 KB Output is correct
20 Correct 208 ms 14796 KB Output is correct
21 Correct 204 ms 14904 KB Output is correct
22 Correct 205 ms 15472 KB Output is correct
23 Correct 238 ms 15560 KB Output is correct
24 Correct 195 ms 15480 KB Output is correct
25 Correct 206 ms 15564 KB Output is correct
26 Correct 206 ms 15496 KB Output is correct
27 Correct 206 ms 15496 KB Output is correct
28 Correct 210 ms 15568 KB Output is correct
29 Correct 215 ms 15640 KB Output is correct
30 Correct 220 ms 15560 KB Output is correct
31 Correct 185 ms 15440 KB Output is correct
32 Correct 222 ms 15520 KB Output is correct
33 Correct 220 ms 15528 KB Output is correct
34 Correct 237 ms 15572 KB Output is correct
35 Correct 223 ms 15460 KB Output is correct
36 Correct 215 ms 15544 KB Output is correct
37 Correct 249 ms 15524 KB Output is correct
38 Correct 211 ms 15572 KB Output is correct
39 Correct 224 ms 15488 KB Output is correct
40 Correct 268 ms 15480 KB Output is correct
41 Correct 207 ms 15564 KB Output is correct
42 Correct 209 ms 15584 KB Output is correct
43 Incorrect 260 ms 15692 KB Output isn't correct
44 Halted 0 ms 0 KB -