답안 #546590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546590 2022-04-07T20:59:29 Z LucaDantas Cubeword (CEOI19_cubeword) C++17
50 / 100
447 ms 17524 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 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);
        }
    }

    vector<array<int,4>> quad;
    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++)
        quad.push_back({a, b, c, d});

    for(int sz = 3; sz <= 10; sz++) for(int i = 0; i < quad.size(); i++) {
        int aq = 0, dp = 1;
        for(int rep = 0; rep < 4; rep++) {
            for(int x = 0; x < maxn; x++) {
                int hm = 1;
                for(int ind = 0; ind < 4; ind++) if(ind != rep)
                    hm = 1ll * hm * edge[sz][x][quad[i][ind]] % mod;
                add(aq, hm);
            }
            dp = 1ll * dp * aq % mod;
            aq = 0;
        }
        add(ans, dp);
    }

    printf("%d\n", ans);
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:36:54: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 4> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int sz = 3; sz <= 10; sz++) for(int i = 0; i < quad.size(); i++) {
      |                                                    ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 402 ms 16588 KB Output is correct
2 Correct 438 ms 16668 KB Output is correct
3 Correct 405 ms 16624 KB Output is correct
4 Correct 400 ms 16644 KB Output is correct
5 Correct 447 ms 16640 KB Output is correct
6 Correct 405 ms 16556 KB Output is correct
7 Correct 390 ms 16592 KB Output is correct
8 Correct 415 ms 16692 KB Output is correct
9 Correct 395 ms 16652 KB Output is correct
10 Correct 411 ms 16652 KB Output is correct
11 Correct 388 ms 16632 KB Output is correct
12 Correct 381 ms 16640 KB Output is correct
13 Correct 369 ms 16608 KB Output is correct
14 Correct 373 ms 16712 KB Output is correct
15 Correct 363 ms 16680 KB Output is correct
16 Correct 395 ms 16592 KB Output is correct
17 Correct 374 ms 16592 KB Output is correct
18 Correct 391 ms 16568 KB Output is correct
19 Correct 383 ms 16540 KB Output is correct
20 Correct 373 ms 16588 KB Output is correct
21 Correct 368 ms 16636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 402 ms 16588 KB Output is correct
2 Correct 438 ms 16668 KB Output is correct
3 Correct 405 ms 16624 KB Output is correct
4 Correct 400 ms 16644 KB Output is correct
5 Correct 447 ms 16640 KB Output is correct
6 Correct 405 ms 16556 KB Output is correct
7 Correct 390 ms 16592 KB Output is correct
8 Correct 415 ms 16692 KB Output is correct
9 Correct 395 ms 16652 KB Output is correct
10 Correct 411 ms 16652 KB Output is correct
11 Correct 388 ms 16632 KB Output is correct
12 Correct 381 ms 16640 KB Output is correct
13 Correct 369 ms 16608 KB Output is correct
14 Correct 373 ms 16712 KB Output is correct
15 Correct 363 ms 16680 KB Output is correct
16 Correct 395 ms 16592 KB Output is correct
17 Correct 374 ms 16592 KB Output is correct
18 Correct 391 ms 16568 KB Output is correct
19 Correct 383 ms 16540 KB Output is correct
20 Correct 373 ms 16588 KB Output is correct
21 Correct 368 ms 16636 KB Output is correct
22 Correct 389 ms 17276 KB Output is correct
23 Correct 382 ms 17260 KB Output is correct
24 Correct 374 ms 17328 KB Output is correct
25 Correct 363 ms 17340 KB Output is correct
26 Correct 362 ms 17404 KB Output is correct
27 Correct 365 ms 17300 KB Output is correct
28 Correct 407 ms 17316 KB Output is correct
29 Correct 368 ms 17268 KB Output is correct
30 Correct 375 ms 17316 KB Output is correct
31 Correct 353 ms 17296 KB Output is correct
32 Correct 370 ms 17244 KB Output is correct
33 Correct 358 ms 17384 KB Output is correct
34 Correct 367 ms 17324 KB Output is correct
35 Correct 365 ms 17352 KB Output is correct
36 Correct 380 ms 17276 KB Output is correct
37 Correct 376 ms 17324 KB Output is correct
38 Correct 356 ms 17296 KB Output is correct
39 Correct 356 ms 17296 KB Output is correct
40 Correct 384 ms 17332 KB Output is correct
41 Correct 354 ms 17352 KB Output is correct
42 Correct 353 ms 17360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 402 ms 16588 KB Output is correct
2 Correct 438 ms 16668 KB Output is correct
3 Correct 405 ms 16624 KB Output is correct
4 Correct 400 ms 16644 KB Output is correct
5 Correct 447 ms 16640 KB Output is correct
6 Correct 405 ms 16556 KB Output is correct
7 Correct 390 ms 16592 KB Output is correct
8 Correct 415 ms 16692 KB Output is correct
9 Correct 395 ms 16652 KB Output is correct
10 Correct 411 ms 16652 KB Output is correct
11 Correct 388 ms 16632 KB Output is correct
12 Correct 381 ms 16640 KB Output is correct
13 Correct 369 ms 16608 KB Output is correct
14 Correct 373 ms 16712 KB Output is correct
15 Correct 363 ms 16680 KB Output is correct
16 Correct 395 ms 16592 KB Output is correct
17 Correct 374 ms 16592 KB Output is correct
18 Correct 391 ms 16568 KB Output is correct
19 Correct 383 ms 16540 KB Output is correct
20 Correct 373 ms 16588 KB Output is correct
21 Correct 368 ms 16636 KB Output is correct
22 Correct 389 ms 17276 KB Output is correct
23 Correct 382 ms 17260 KB Output is correct
24 Correct 374 ms 17328 KB Output is correct
25 Correct 363 ms 17340 KB Output is correct
26 Correct 362 ms 17404 KB Output is correct
27 Correct 365 ms 17300 KB Output is correct
28 Correct 407 ms 17316 KB Output is correct
29 Correct 368 ms 17268 KB Output is correct
30 Correct 375 ms 17316 KB Output is correct
31 Correct 353 ms 17296 KB Output is correct
32 Correct 370 ms 17244 KB Output is correct
33 Correct 358 ms 17384 KB Output is correct
34 Correct 367 ms 17324 KB Output is correct
35 Correct 365 ms 17352 KB Output is correct
36 Correct 380 ms 17276 KB Output is correct
37 Correct 376 ms 17324 KB Output is correct
38 Correct 356 ms 17296 KB Output is correct
39 Correct 356 ms 17296 KB Output is correct
40 Correct 384 ms 17332 KB Output is correct
41 Correct 354 ms 17352 KB Output is correct
42 Correct 353 ms 17360 KB Output is correct
43 Incorrect 363 ms 17524 KB Output isn't correct
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 402 ms 16588 KB Output is correct
2 Correct 438 ms 16668 KB Output is correct
3 Correct 405 ms 16624 KB Output is correct
4 Correct 400 ms 16644 KB Output is correct
5 Correct 447 ms 16640 KB Output is correct
6 Correct 405 ms 16556 KB Output is correct
7 Correct 390 ms 16592 KB Output is correct
8 Correct 415 ms 16692 KB Output is correct
9 Correct 395 ms 16652 KB Output is correct
10 Correct 411 ms 16652 KB Output is correct
11 Correct 388 ms 16632 KB Output is correct
12 Correct 381 ms 16640 KB Output is correct
13 Correct 369 ms 16608 KB Output is correct
14 Correct 373 ms 16712 KB Output is correct
15 Correct 363 ms 16680 KB Output is correct
16 Correct 395 ms 16592 KB Output is correct
17 Correct 374 ms 16592 KB Output is correct
18 Correct 391 ms 16568 KB Output is correct
19 Correct 383 ms 16540 KB Output is correct
20 Correct 373 ms 16588 KB Output is correct
21 Correct 368 ms 16636 KB Output is correct
22 Correct 389 ms 17276 KB Output is correct
23 Correct 382 ms 17260 KB Output is correct
24 Correct 374 ms 17328 KB Output is correct
25 Correct 363 ms 17340 KB Output is correct
26 Correct 362 ms 17404 KB Output is correct
27 Correct 365 ms 17300 KB Output is correct
28 Correct 407 ms 17316 KB Output is correct
29 Correct 368 ms 17268 KB Output is correct
30 Correct 375 ms 17316 KB Output is correct
31 Correct 353 ms 17296 KB Output is correct
32 Correct 370 ms 17244 KB Output is correct
33 Correct 358 ms 17384 KB Output is correct
34 Correct 367 ms 17324 KB Output is correct
35 Correct 365 ms 17352 KB Output is correct
36 Correct 380 ms 17276 KB Output is correct
37 Correct 376 ms 17324 KB Output is correct
38 Correct 356 ms 17296 KB Output is correct
39 Correct 356 ms 17296 KB Output is correct
40 Correct 384 ms 17332 KB Output is correct
41 Correct 354 ms 17352 KB Output is correct
42 Correct 353 ms 17360 KB Output is correct
43 Incorrect 363 ms 17524 KB Output isn't correct
44 Halted 0 ms 0 KB -