답안 #572376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572376 2022-06-04T09:59:20 Z piOOE Cubeword (CEOI19_cubeword) C++17
50 / 100
904 ms 14124 KB
#include <bits/stdc++.h>

using namespace std;

#define sz(x) ((int)size(x))
#define all(x) begin(x), end(x)
#define trace(x) cout << #x << ": " << (x) << endl;

typedef long long ll;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }

const int N = 8, A = 16, L = 11, mod = 998244353;
const ll infL = 3e18;

int g[N][3] = {{1, 2, 4},
               {0, 3, 5},
               {0, 3, 6},
               {1, 2, 7},
               {0, 5, 6},
               {1, 4, 7},
               {2, 4, 7},
               {3, 5, 6}};

int n;
int cnt[A][A][L], used[N];
int ans = 0, len = 0;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    vector<string> stt;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        string ss = s;
        reverse(all(ss));
        stt.push_back(ss);
        stt.push_back(s);
    }
    sort(all(stt));
    stt.resize(unique(all(stt)) - begin(stt));
    for (string s: stt) {
        ++cnt[islower(s[0]) ? int(s[0] - 'a') : s[0] - 'A' + 16][islower(s.back()) ? int(s.back() - 'a') : s.back() - 'A' + 16][sz(s)];
    }
    for (len = 1; len < L; ++len) {
        memset(used, -1, sizeof(used));
        for (int x0 = 0; x0 < A; ++x0) {
            used[0] = x0;
            for (int x3 = 0; x3 < A; ++x3) {
                used[3] = x3;
                for (int x5 = 0; x5 < A; ++x5) {
                    used[5] = x5;
                    for (int x6 = 0; x6 < A; ++x6) {
                        used[6] = x6;
                        int nw = 1;
                        for (int i = 0; i < N; ++i) {
                            if (used[i] == -1) {
                                int sum = 0;
                                for (int x = 0; x < A; ++x) {
                                    int now = 1;
                                    for (int to : g[i]) {
                                        assert(used[to] != -1);
                                        now = (now * (ll)cnt[x][used[to]][len]) % mod;
                                    }
                                    sum = (sum + now) % mod;
                                }
                                nw = (nw * (ll)sum) % mod;
                            }
                        }
                        ans = (ans + nw) % mod;
                    }
                }
            }
        }
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 631 ms 9416 KB Output is correct
2 Correct 647 ms 9376 KB Output is correct
3 Correct 611 ms 9416 KB Output is correct
4 Correct 636 ms 9328 KB Output is correct
5 Correct 659 ms 9408 KB Output is correct
6 Correct 638 ms 9416 KB Output is correct
7 Correct 603 ms 9340 KB Output is correct
8 Correct 904 ms 9412 KB Output is correct
9 Correct 665 ms 9400 KB Output is correct
10 Correct 638 ms 9396 KB Output is correct
11 Correct 641 ms 9384 KB Output is correct
12 Correct 640 ms 9380 KB Output is correct
13 Correct 684 ms 9416 KB Output is correct
14 Correct 704 ms 9412 KB Output is correct
15 Correct 652 ms 9380 KB Output is correct
16 Correct 623 ms 9416 KB Output is correct
17 Correct 639 ms 9356 KB Output is correct
18 Correct 659 ms 9396 KB Output is correct
19 Correct 645 ms 9408 KB Output is correct
20 Correct 647 ms 9416 KB Output is correct
21 Correct 633 ms 9392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 631 ms 9416 KB Output is correct
2 Correct 647 ms 9376 KB Output is correct
3 Correct 611 ms 9416 KB Output is correct
4 Correct 636 ms 9328 KB Output is correct
5 Correct 659 ms 9408 KB Output is correct
6 Correct 638 ms 9416 KB Output is correct
7 Correct 603 ms 9340 KB Output is correct
8 Correct 904 ms 9412 KB Output is correct
9 Correct 665 ms 9400 KB Output is correct
10 Correct 638 ms 9396 KB Output is correct
11 Correct 641 ms 9384 KB Output is correct
12 Correct 640 ms 9380 KB Output is correct
13 Correct 684 ms 9416 KB Output is correct
14 Correct 704 ms 9412 KB Output is correct
15 Correct 652 ms 9380 KB Output is correct
16 Correct 623 ms 9416 KB Output is correct
17 Correct 639 ms 9356 KB Output is correct
18 Correct 659 ms 9396 KB Output is correct
19 Correct 645 ms 9408 KB Output is correct
20 Correct 647 ms 9416 KB Output is correct
21 Correct 633 ms 9392 KB Output is correct
22 Correct 643 ms 9324 KB Output is correct
23 Correct 625 ms 9416 KB Output is correct
24 Correct 636 ms 9416 KB Output is correct
25 Correct 648 ms 9416 KB Output is correct
26 Correct 636 ms 9420 KB Output is correct
27 Correct 634 ms 9404 KB Output is correct
28 Correct 657 ms 9392 KB Output is correct
29 Correct 662 ms 9348 KB Output is correct
30 Correct 686 ms 9416 KB Output is correct
31 Correct 753 ms 9416 KB Output is correct
32 Correct 693 ms 9392 KB Output is correct
33 Correct 706 ms 9416 KB Output is correct
34 Correct 694 ms 9452 KB Output is correct
35 Correct 739 ms 9340 KB Output is correct
36 Correct 698 ms 9416 KB Output is correct
37 Correct 681 ms 9408 KB Output is correct
38 Correct 685 ms 9432 KB Output is correct
39 Correct 759 ms 9428 KB Output is correct
40 Correct 666 ms 9416 KB Output is correct
41 Correct 729 ms 9416 KB Output is correct
42 Correct 672 ms 9352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 631 ms 9416 KB Output is correct
2 Correct 647 ms 9376 KB Output is correct
3 Correct 611 ms 9416 KB Output is correct
4 Correct 636 ms 9328 KB Output is correct
5 Correct 659 ms 9408 KB Output is correct
6 Correct 638 ms 9416 KB Output is correct
7 Correct 603 ms 9340 KB Output is correct
8 Correct 904 ms 9412 KB Output is correct
9 Correct 665 ms 9400 KB Output is correct
10 Correct 638 ms 9396 KB Output is correct
11 Correct 641 ms 9384 KB Output is correct
12 Correct 640 ms 9380 KB Output is correct
13 Correct 684 ms 9416 KB Output is correct
14 Correct 704 ms 9412 KB Output is correct
15 Correct 652 ms 9380 KB Output is correct
16 Correct 623 ms 9416 KB Output is correct
17 Correct 639 ms 9356 KB Output is correct
18 Correct 659 ms 9396 KB Output is correct
19 Correct 645 ms 9408 KB Output is correct
20 Correct 647 ms 9416 KB Output is correct
21 Correct 633 ms 9392 KB Output is correct
22 Correct 643 ms 9324 KB Output is correct
23 Correct 625 ms 9416 KB Output is correct
24 Correct 636 ms 9416 KB Output is correct
25 Correct 648 ms 9416 KB Output is correct
26 Correct 636 ms 9420 KB Output is correct
27 Correct 634 ms 9404 KB Output is correct
28 Correct 657 ms 9392 KB Output is correct
29 Correct 662 ms 9348 KB Output is correct
30 Correct 686 ms 9416 KB Output is correct
31 Correct 753 ms 9416 KB Output is correct
32 Correct 693 ms 9392 KB Output is correct
33 Correct 706 ms 9416 KB Output is correct
34 Correct 694 ms 9452 KB Output is correct
35 Correct 739 ms 9340 KB Output is correct
36 Correct 698 ms 9416 KB Output is correct
37 Correct 681 ms 9408 KB Output is correct
38 Correct 685 ms 9432 KB Output is correct
39 Correct 759 ms 9428 KB Output is correct
40 Correct 666 ms 9416 KB Output is correct
41 Correct 729 ms 9416 KB Output is correct
42 Correct 672 ms 9352 KB Output is correct
43 Runtime error 699 ms 14124 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 631 ms 9416 KB Output is correct
2 Correct 647 ms 9376 KB Output is correct
3 Correct 611 ms 9416 KB Output is correct
4 Correct 636 ms 9328 KB Output is correct
5 Correct 659 ms 9408 KB Output is correct
6 Correct 638 ms 9416 KB Output is correct
7 Correct 603 ms 9340 KB Output is correct
8 Correct 904 ms 9412 KB Output is correct
9 Correct 665 ms 9400 KB Output is correct
10 Correct 638 ms 9396 KB Output is correct
11 Correct 641 ms 9384 KB Output is correct
12 Correct 640 ms 9380 KB Output is correct
13 Correct 684 ms 9416 KB Output is correct
14 Correct 704 ms 9412 KB Output is correct
15 Correct 652 ms 9380 KB Output is correct
16 Correct 623 ms 9416 KB Output is correct
17 Correct 639 ms 9356 KB Output is correct
18 Correct 659 ms 9396 KB Output is correct
19 Correct 645 ms 9408 KB Output is correct
20 Correct 647 ms 9416 KB Output is correct
21 Correct 633 ms 9392 KB Output is correct
22 Correct 643 ms 9324 KB Output is correct
23 Correct 625 ms 9416 KB Output is correct
24 Correct 636 ms 9416 KB Output is correct
25 Correct 648 ms 9416 KB Output is correct
26 Correct 636 ms 9420 KB Output is correct
27 Correct 634 ms 9404 KB Output is correct
28 Correct 657 ms 9392 KB Output is correct
29 Correct 662 ms 9348 KB Output is correct
30 Correct 686 ms 9416 KB Output is correct
31 Correct 753 ms 9416 KB Output is correct
32 Correct 693 ms 9392 KB Output is correct
33 Correct 706 ms 9416 KB Output is correct
34 Correct 694 ms 9452 KB Output is correct
35 Correct 739 ms 9340 KB Output is correct
36 Correct 698 ms 9416 KB Output is correct
37 Correct 681 ms 9408 KB Output is correct
38 Correct 685 ms 9432 KB Output is correct
39 Correct 759 ms 9428 KB Output is correct
40 Correct 666 ms 9416 KB Output is correct
41 Correct 729 ms 9416 KB Output is correct
42 Correct 672 ms 9352 KB Output is correct
43 Runtime error 699 ms 14124 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -