Submission #546613

# Submission time Handle Problem Language Result Execution time Memory
546613 2022-04-07T21:22:27 Z LucaDantas Cubeword (CEOI19_cubeword) C++17
50 / 100
399 ms 16660 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 >= 'a') 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 341 ms 15840 KB Output is correct
2 Correct 350 ms 15828 KB Output is correct
3 Correct 335 ms 15816 KB Output is correct
4 Correct 339 ms 15824 KB Output is correct
5 Correct 351 ms 15912 KB Output is correct
6 Correct 359 ms 15832 KB Output is correct
7 Correct 342 ms 15840 KB Output is correct
8 Correct 347 ms 15820 KB Output is correct
9 Correct 336 ms 15796 KB Output is correct
10 Correct 343 ms 15912 KB Output is correct
11 Correct 359 ms 15836 KB Output is correct
12 Correct 352 ms 15820 KB Output is correct
13 Correct 350 ms 15856 KB Output is correct
14 Correct 332 ms 15720 KB Output is correct
15 Correct 335 ms 15828 KB Output is correct
16 Correct 351 ms 15840 KB Output is correct
17 Correct 331 ms 15832 KB Output is correct
18 Correct 343 ms 15940 KB Output is correct
19 Correct 341 ms 15716 KB Output is correct
20 Correct 399 ms 15836 KB Output is correct
21 Correct 326 ms 15816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 341 ms 15840 KB Output is correct
2 Correct 350 ms 15828 KB Output is correct
3 Correct 335 ms 15816 KB Output is correct
4 Correct 339 ms 15824 KB Output is correct
5 Correct 351 ms 15912 KB Output is correct
6 Correct 359 ms 15832 KB Output is correct
7 Correct 342 ms 15840 KB Output is correct
8 Correct 347 ms 15820 KB Output is correct
9 Correct 336 ms 15796 KB Output is correct
10 Correct 343 ms 15912 KB Output is correct
11 Correct 359 ms 15836 KB Output is correct
12 Correct 352 ms 15820 KB Output is correct
13 Correct 350 ms 15856 KB Output is correct
14 Correct 332 ms 15720 KB Output is correct
15 Correct 335 ms 15828 KB Output is correct
16 Correct 351 ms 15840 KB Output is correct
17 Correct 331 ms 15832 KB Output is correct
18 Correct 343 ms 15940 KB Output is correct
19 Correct 341 ms 15716 KB Output is correct
20 Correct 399 ms 15836 KB Output is correct
21 Correct 326 ms 15816 KB Output is correct
22 Correct 355 ms 16452 KB Output is correct
23 Correct 349 ms 16568 KB Output is correct
24 Correct 392 ms 16504 KB Output is correct
25 Correct 342 ms 16464 KB Output is correct
26 Correct 345 ms 16424 KB Output is correct
27 Correct 338 ms 16464 KB Output is correct
28 Correct 343 ms 16408 KB Output is correct
29 Correct 354 ms 16500 KB Output is correct
30 Correct 346 ms 16572 KB Output is correct
31 Correct 324 ms 16488 KB Output is correct
32 Correct 341 ms 16452 KB Output is correct
33 Correct 352 ms 16484 KB Output is correct
34 Correct 360 ms 16492 KB Output is correct
35 Correct 295 ms 16496 KB Output is correct
36 Correct 329 ms 16456 KB Output is correct
37 Correct 328 ms 16416 KB Output is correct
38 Correct 324 ms 16492 KB Output is correct
39 Correct 310 ms 16448 KB Output is correct
40 Correct 290 ms 16428 KB Output is correct
41 Correct 308 ms 16460 KB Output is correct
42 Correct 308 ms 16608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 341 ms 15840 KB Output is correct
2 Correct 350 ms 15828 KB Output is correct
3 Correct 335 ms 15816 KB Output is correct
4 Correct 339 ms 15824 KB Output is correct
5 Correct 351 ms 15912 KB Output is correct
6 Correct 359 ms 15832 KB Output is correct
7 Correct 342 ms 15840 KB Output is correct
8 Correct 347 ms 15820 KB Output is correct
9 Correct 336 ms 15796 KB Output is correct
10 Correct 343 ms 15912 KB Output is correct
11 Correct 359 ms 15836 KB Output is correct
12 Correct 352 ms 15820 KB Output is correct
13 Correct 350 ms 15856 KB Output is correct
14 Correct 332 ms 15720 KB Output is correct
15 Correct 335 ms 15828 KB Output is correct
16 Correct 351 ms 15840 KB Output is correct
17 Correct 331 ms 15832 KB Output is correct
18 Correct 343 ms 15940 KB Output is correct
19 Correct 341 ms 15716 KB Output is correct
20 Correct 399 ms 15836 KB Output is correct
21 Correct 326 ms 15816 KB Output is correct
22 Correct 355 ms 16452 KB Output is correct
23 Correct 349 ms 16568 KB Output is correct
24 Correct 392 ms 16504 KB Output is correct
25 Correct 342 ms 16464 KB Output is correct
26 Correct 345 ms 16424 KB Output is correct
27 Correct 338 ms 16464 KB Output is correct
28 Correct 343 ms 16408 KB Output is correct
29 Correct 354 ms 16500 KB Output is correct
30 Correct 346 ms 16572 KB Output is correct
31 Correct 324 ms 16488 KB Output is correct
32 Correct 341 ms 16452 KB Output is correct
33 Correct 352 ms 16484 KB Output is correct
34 Correct 360 ms 16492 KB Output is correct
35 Correct 295 ms 16496 KB Output is correct
36 Correct 329 ms 16456 KB Output is correct
37 Correct 328 ms 16416 KB Output is correct
38 Correct 324 ms 16492 KB Output is correct
39 Correct 310 ms 16448 KB Output is correct
40 Correct 290 ms 16428 KB Output is correct
41 Correct 308 ms 16460 KB Output is correct
42 Correct 308 ms 16608 KB Output is correct
43 Incorrect 287 ms 16660 KB Output isn't correct
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 341 ms 15840 KB Output is correct
2 Correct 350 ms 15828 KB Output is correct
3 Correct 335 ms 15816 KB Output is correct
4 Correct 339 ms 15824 KB Output is correct
5 Correct 351 ms 15912 KB Output is correct
6 Correct 359 ms 15832 KB Output is correct
7 Correct 342 ms 15840 KB Output is correct
8 Correct 347 ms 15820 KB Output is correct
9 Correct 336 ms 15796 KB Output is correct
10 Correct 343 ms 15912 KB Output is correct
11 Correct 359 ms 15836 KB Output is correct
12 Correct 352 ms 15820 KB Output is correct
13 Correct 350 ms 15856 KB Output is correct
14 Correct 332 ms 15720 KB Output is correct
15 Correct 335 ms 15828 KB Output is correct
16 Correct 351 ms 15840 KB Output is correct
17 Correct 331 ms 15832 KB Output is correct
18 Correct 343 ms 15940 KB Output is correct
19 Correct 341 ms 15716 KB Output is correct
20 Correct 399 ms 15836 KB Output is correct
21 Correct 326 ms 15816 KB Output is correct
22 Correct 355 ms 16452 KB Output is correct
23 Correct 349 ms 16568 KB Output is correct
24 Correct 392 ms 16504 KB Output is correct
25 Correct 342 ms 16464 KB Output is correct
26 Correct 345 ms 16424 KB Output is correct
27 Correct 338 ms 16464 KB Output is correct
28 Correct 343 ms 16408 KB Output is correct
29 Correct 354 ms 16500 KB Output is correct
30 Correct 346 ms 16572 KB Output is correct
31 Correct 324 ms 16488 KB Output is correct
32 Correct 341 ms 16452 KB Output is correct
33 Correct 352 ms 16484 KB Output is correct
34 Correct 360 ms 16492 KB Output is correct
35 Correct 295 ms 16496 KB Output is correct
36 Correct 329 ms 16456 KB Output is correct
37 Correct 328 ms 16416 KB Output is correct
38 Correct 324 ms 16492 KB Output is correct
39 Correct 310 ms 16448 KB Output is correct
40 Correct 290 ms 16428 KB Output is correct
41 Correct 308 ms 16460 KB Output is correct
42 Correct 308 ms 16608 KB Output is correct
43 Incorrect 287 ms 16660 KB Output isn't correct
44 Halted 0 ms 0 KB -