Submission #546610

# Submission time Handle Problem Language Result Execution time Memory
546610 2022-04-07T21:21:25 Z LucaDantas Cubeword (CEOI19_cubeword) C++17
50 / 100
355 ms 16712 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 = 32, mod = 998244353; // subtasks 1-2

int ans;

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

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

int id(char c) { if(c <= 'p') return c-'a'; 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 271 ms 15848 KB Output is correct
2 Correct 291 ms 15924 KB Output is correct
3 Correct 268 ms 15820 KB Output is correct
4 Correct 282 ms 15708 KB Output is correct
5 Correct 290 ms 15916 KB Output is correct
6 Correct 280 ms 15728 KB Output is correct
7 Correct 327 ms 15844 KB Output is correct
8 Correct 292 ms 15764 KB Output is correct
9 Correct 332 ms 15820 KB Output is correct
10 Correct 312 ms 15936 KB Output is correct
11 Correct 323 ms 15832 KB Output is correct
12 Correct 311 ms 15820 KB Output is correct
13 Correct 350 ms 15852 KB Output is correct
14 Correct 307 ms 15876 KB Output is correct
15 Correct 294 ms 15820 KB Output is correct
16 Correct 306 ms 15780 KB Output is correct
17 Correct 316 ms 15756 KB Output is correct
18 Correct 355 ms 15724 KB Output is correct
19 Correct 352 ms 15764 KB Output is correct
20 Correct 332 ms 15752 KB Output is correct
21 Correct 323 ms 15820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 271 ms 15848 KB Output is correct
2 Correct 291 ms 15924 KB Output is correct
3 Correct 268 ms 15820 KB Output is correct
4 Correct 282 ms 15708 KB Output is correct
5 Correct 290 ms 15916 KB Output is correct
6 Correct 280 ms 15728 KB Output is correct
7 Correct 327 ms 15844 KB Output is correct
8 Correct 292 ms 15764 KB Output is correct
9 Correct 332 ms 15820 KB Output is correct
10 Correct 312 ms 15936 KB Output is correct
11 Correct 323 ms 15832 KB Output is correct
12 Correct 311 ms 15820 KB Output is correct
13 Correct 350 ms 15852 KB Output is correct
14 Correct 307 ms 15876 KB Output is correct
15 Correct 294 ms 15820 KB Output is correct
16 Correct 306 ms 15780 KB Output is correct
17 Correct 316 ms 15756 KB Output is correct
18 Correct 355 ms 15724 KB Output is correct
19 Correct 352 ms 15764 KB Output is correct
20 Correct 332 ms 15752 KB Output is correct
21 Correct 323 ms 15820 KB Output is correct
22 Correct 286 ms 16384 KB Output is correct
23 Correct 300 ms 16496 KB Output is correct
24 Correct 288 ms 16544 KB Output is correct
25 Correct 298 ms 16492 KB Output is correct
26 Correct 297 ms 16564 KB Output is correct
27 Correct 291 ms 16612 KB Output is correct
28 Correct 294 ms 16436 KB Output is correct
29 Correct 314 ms 16556 KB Output is correct
30 Correct 281 ms 16484 KB Output is correct
31 Correct 297 ms 16488 KB Output is correct
32 Correct 301 ms 16484 KB Output is correct
33 Correct 297 ms 16372 KB Output is correct
34 Correct 306 ms 16616 KB Output is correct
35 Correct 284 ms 16472 KB Output is correct
36 Correct 313 ms 16444 KB Output is correct
37 Correct 298 ms 16500 KB Output is correct
38 Correct 318 ms 16528 KB Output is correct
39 Correct 298 ms 16376 KB Output is correct
40 Correct 298 ms 16460 KB Output is correct
41 Correct 326 ms 16460 KB Output is correct
42 Correct 285 ms 16500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 271 ms 15848 KB Output is correct
2 Correct 291 ms 15924 KB Output is correct
3 Correct 268 ms 15820 KB Output is correct
4 Correct 282 ms 15708 KB Output is correct
5 Correct 290 ms 15916 KB Output is correct
6 Correct 280 ms 15728 KB Output is correct
7 Correct 327 ms 15844 KB Output is correct
8 Correct 292 ms 15764 KB Output is correct
9 Correct 332 ms 15820 KB Output is correct
10 Correct 312 ms 15936 KB Output is correct
11 Correct 323 ms 15832 KB Output is correct
12 Correct 311 ms 15820 KB Output is correct
13 Correct 350 ms 15852 KB Output is correct
14 Correct 307 ms 15876 KB Output is correct
15 Correct 294 ms 15820 KB Output is correct
16 Correct 306 ms 15780 KB Output is correct
17 Correct 316 ms 15756 KB Output is correct
18 Correct 355 ms 15724 KB Output is correct
19 Correct 352 ms 15764 KB Output is correct
20 Correct 332 ms 15752 KB Output is correct
21 Correct 323 ms 15820 KB Output is correct
22 Correct 286 ms 16384 KB Output is correct
23 Correct 300 ms 16496 KB Output is correct
24 Correct 288 ms 16544 KB Output is correct
25 Correct 298 ms 16492 KB Output is correct
26 Correct 297 ms 16564 KB Output is correct
27 Correct 291 ms 16612 KB Output is correct
28 Correct 294 ms 16436 KB Output is correct
29 Correct 314 ms 16556 KB Output is correct
30 Correct 281 ms 16484 KB Output is correct
31 Correct 297 ms 16488 KB Output is correct
32 Correct 301 ms 16484 KB Output is correct
33 Correct 297 ms 16372 KB Output is correct
34 Correct 306 ms 16616 KB Output is correct
35 Correct 284 ms 16472 KB Output is correct
36 Correct 313 ms 16444 KB Output is correct
37 Correct 298 ms 16500 KB Output is correct
38 Correct 318 ms 16528 KB Output is correct
39 Correct 298 ms 16376 KB Output is correct
40 Correct 298 ms 16460 KB Output is correct
41 Correct 326 ms 16460 KB Output is correct
42 Correct 285 ms 16500 KB Output is correct
43 Incorrect 320 ms 16712 KB Output isn't correct
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 271 ms 15848 KB Output is correct
2 Correct 291 ms 15924 KB Output is correct
3 Correct 268 ms 15820 KB Output is correct
4 Correct 282 ms 15708 KB Output is correct
5 Correct 290 ms 15916 KB Output is correct
6 Correct 280 ms 15728 KB Output is correct
7 Correct 327 ms 15844 KB Output is correct
8 Correct 292 ms 15764 KB Output is correct
9 Correct 332 ms 15820 KB Output is correct
10 Correct 312 ms 15936 KB Output is correct
11 Correct 323 ms 15832 KB Output is correct
12 Correct 311 ms 15820 KB Output is correct
13 Correct 350 ms 15852 KB Output is correct
14 Correct 307 ms 15876 KB Output is correct
15 Correct 294 ms 15820 KB Output is correct
16 Correct 306 ms 15780 KB Output is correct
17 Correct 316 ms 15756 KB Output is correct
18 Correct 355 ms 15724 KB Output is correct
19 Correct 352 ms 15764 KB Output is correct
20 Correct 332 ms 15752 KB Output is correct
21 Correct 323 ms 15820 KB Output is correct
22 Correct 286 ms 16384 KB Output is correct
23 Correct 300 ms 16496 KB Output is correct
24 Correct 288 ms 16544 KB Output is correct
25 Correct 298 ms 16492 KB Output is correct
26 Correct 297 ms 16564 KB Output is correct
27 Correct 291 ms 16612 KB Output is correct
28 Correct 294 ms 16436 KB Output is correct
29 Correct 314 ms 16556 KB Output is correct
30 Correct 281 ms 16484 KB Output is correct
31 Correct 297 ms 16488 KB Output is correct
32 Correct 301 ms 16484 KB Output is correct
33 Correct 297 ms 16372 KB Output is correct
34 Correct 306 ms 16616 KB Output is correct
35 Correct 284 ms 16472 KB Output is correct
36 Correct 313 ms 16444 KB Output is correct
37 Correct 298 ms 16500 KB Output is correct
38 Correct 318 ms 16528 KB Output is correct
39 Correct 298 ms 16376 KB Output is correct
40 Correct 298 ms 16460 KB Output is correct
41 Correct 326 ms 16460 KB Output is correct
42 Correct 285 ms 16500 KB Output is correct
43 Incorrect 320 ms 16712 KB Output isn't correct
44 Halted 0 ms 0 KB -