# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
207919 | 2020-03-09T12:21:05 Z | E869120 | Cubeword (CEOI19_cubeword) | C++14 | 767 ms | 40780 KB |
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; #pragma warning (disable: 4996) const long long mod = 998244353; const int MAX_VAL = 62; int N; string S[1 << 18]; char c[10009]; int cnt[62][62]; long long ret[62][62][62]; long long teisuu[62][62][62][62]; void init() { for (int i = 0; i < 62; i++) { for (int j = 0; j < 62; j++) { for (int k = 0; k < 62; k++) { for (int l = 0; l < 62; l++) { int c[4] = { i,j,k,l }; sort(c, c + 4); teisuu[c[0]][c[1]][c[2]][c[3]]++; } } } } } int getc(char d) { if ('a' <= d && d <= 'z') return (d - 'a'); if ('A' <= d && d <= 'Z') return (d - 'A') + 26; return (d - '0') + 52; } long long getcnt(int v1, int v2) { return cnt[v1][v2]; } long long solve(int pos) { for (int i = 0; i < 62 * 62; i++) cnt[i / 62][i % 62] = 0; vector<string> vec; for (int i = 1; i <= N; i++) { if (S[i].size() != pos) continue; string T = S[i]; reverse(T.begin(), T.end()); vec.push_back(S[i]); vec.push_back(T); } sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end()); for (string i : vec) { int c1 = getc(i[0]), c2 = getc(i[i.size() - 1]); cnt[c1][c2] += 1; } for (int i = 0; i < MAX_VAL; i++) { for (int j = i; j < MAX_VAL; j++) { for (int k = j; k < MAX_VAL; k++) { ret[i][j][k] = 0; for (int l = 0; l < MAX_VAL; l++) { ret[i][j][k] += getcnt(i, l) * getcnt(j, l) * getcnt(k, l); ret[i][j][k] %= mod; } } } } long long val = 0; for (int i = 0; i < MAX_VAL; i++) { for (int j = i; j < MAX_VAL; j++) { for (int k = j; k < MAX_VAL; k++) { for (int l = k; l < MAX_VAL; l++) { sort(c, c + 4); val += ((ret[i][j][k] * ret[i][j][l] % mod) * (ret[i][k][l] * ret[j][k][l] % mod) % mod) * teisuu[i][j][k][l]; val %= mod; } } } } return val; } int main() { cin >> N; init(); for (int i = 1; i <= N; i++) { for (int j = 0; j < 11; j++) c[j] = 0; scanf("%s", &c); for (int j = 0; j < 11; j++) { if (c[j] == 0) break; S[i] += c[j]; } } long long ans = 0; for (int i = 3; i <= 10; i++) { ans += solve(i); ans %= mod; } cout << ans << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 697 ms | 40664 KB | Output is correct |
2 | Correct | 693 ms | 40740 KB | Output is correct |
3 | Correct | 692 ms | 40688 KB | Output is correct |
4 | Correct | 676 ms | 40612 KB | Output is correct |
5 | Correct | 668 ms | 40532 KB | Output is correct |
6 | Correct | 686 ms | 40536 KB | Output is correct |
7 | Correct | 684 ms | 40596 KB | Output is correct |
8 | Correct | 690 ms | 40552 KB | Output is correct |
9 | Correct | 674 ms | 40556 KB | Output is correct |
10 | Correct | 686 ms | 40552 KB | Output is correct |
11 | Correct | 673 ms | 40556 KB | Output is correct |
12 | Correct | 680 ms | 40724 KB | Output is correct |
13 | Correct | 676 ms | 40580 KB | Output is correct |
14 | Correct | 674 ms | 40612 KB | Output is correct |
15 | Correct | 666 ms | 40592 KB | Output is correct |
16 | Correct | 689 ms | 40600 KB | Output is correct |
17 | Correct | 702 ms | 40604 KB | Output is correct |
18 | Correct | 703 ms | 40780 KB | Output is correct |
19 | Correct | 702 ms | 40540 KB | Output is correct |
20 | Correct | 684 ms | 40532 KB | Output is correct |
21 | Correct | 684 ms | 40512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 697 ms | 40664 KB | Output is correct |
2 | Correct | 693 ms | 40740 KB | Output is correct |
3 | Correct | 692 ms | 40688 KB | Output is correct |
4 | Correct | 676 ms | 40612 KB | Output is correct |
5 | Correct | 668 ms | 40532 KB | Output is correct |
6 | Correct | 686 ms | 40536 KB | Output is correct |
7 | Correct | 684 ms | 40596 KB | Output is correct |
8 | Correct | 690 ms | 40552 KB | Output is correct |
9 | Correct | 674 ms | 40556 KB | Output is correct |
10 | Correct | 686 ms | 40552 KB | Output is correct |
11 | Correct | 673 ms | 40556 KB | Output is correct |
12 | Correct | 680 ms | 40724 KB | Output is correct |
13 | Correct | 676 ms | 40580 KB | Output is correct |
14 | Correct | 674 ms | 40612 KB | Output is correct |
15 | Correct | 666 ms | 40592 KB | Output is correct |
16 | Correct | 689 ms | 40600 KB | Output is correct |
17 | Correct | 702 ms | 40604 KB | Output is correct |
18 | Correct | 703 ms | 40780 KB | Output is correct |
19 | Correct | 702 ms | 40540 KB | Output is correct |
20 | Correct | 684 ms | 40532 KB | Output is correct |
21 | Correct | 684 ms | 40512 KB | Output is correct |
22 | Correct | 696 ms | 39272 KB | Output is correct |
23 | Correct | 706 ms | 39336 KB | Output is correct |
24 | Correct | 671 ms | 39256 KB | Output is correct |
25 | Correct | 681 ms | 39164 KB | Output is correct |
26 | Correct | 674 ms | 39180 KB | Output is correct |
27 | Correct | 681 ms | 39240 KB | Output is correct |
28 | Correct | 694 ms | 39236 KB | Output is correct |
29 | Correct | 689 ms | 39356 KB | Output is correct |
30 | Correct | 678 ms | 39180 KB | Output is correct |
31 | Correct | 685 ms | 39172 KB | Output is correct |
32 | Correct | 674 ms | 39204 KB | Output is correct |
33 | Correct | 677 ms | 39320 KB | Output is correct |
34 | Correct | 683 ms | 39344 KB | Output is correct |
35 | Correct | 698 ms | 39188 KB | Output is correct |
36 | Correct | 681 ms | 39188 KB | Output is correct |
37 | Correct | 673 ms | 39200 KB | Output is correct |
38 | Correct | 681 ms | 39204 KB | Output is correct |
39 | Correct | 685 ms | 39308 KB | Output is correct |
40 | Correct | 671 ms | 39200 KB | Output is correct |
41 | Correct | 674 ms | 39232 KB | Output is correct |
42 | Correct | 683 ms | 39340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 697 ms | 40664 KB | Output is correct |
2 | Correct | 693 ms | 40740 KB | Output is correct |
3 | Correct | 692 ms | 40688 KB | Output is correct |
4 | Correct | 676 ms | 40612 KB | Output is correct |
5 | Correct | 668 ms | 40532 KB | Output is correct |
6 | Correct | 686 ms | 40536 KB | Output is correct |
7 | Correct | 684 ms | 40596 KB | Output is correct |
8 | Correct | 690 ms | 40552 KB | Output is correct |
9 | Correct | 674 ms | 40556 KB | Output is correct |
10 | Correct | 686 ms | 40552 KB | Output is correct |
11 | Correct | 673 ms | 40556 KB | Output is correct |
12 | Correct | 680 ms | 40724 KB | Output is correct |
13 | Correct | 676 ms | 40580 KB | Output is correct |
14 | Correct | 674 ms | 40612 KB | Output is correct |
15 | Correct | 666 ms | 40592 KB | Output is correct |
16 | Correct | 689 ms | 40600 KB | Output is correct |
17 | Correct | 702 ms | 40604 KB | Output is correct |
18 | Correct | 703 ms | 40780 KB | Output is correct |
19 | Correct | 702 ms | 40540 KB | Output is correct |
20 | Correct | 684 ms | 40532 KB | Output is correct |
21 | Correct | 684 ms | 40512 KB | Output is correct |
22 | Correct | 696 ms | 39272 KB | Output is correct |
23 | Correct | 706 ms | 39336 KB | Output is correct |
24 | Correct | 671 ms | 39256 KB | Output is correct |
25 | Correct | 681 ms | 39164 KB | Output is correct |
26 | Correct | 674 ms | 39180 KB | Output is correct |
27 | Correct | 681 ms | 39240 KB | Output is correct |
28 | Correct | 694 ms | 39236 KB | Output is correct |
29 | Correct | 689 ms | 39356 KB | Output is correct |
30 | Correct | 678 ms | 39180 KB | Output is correct |
31 | Correct | 685 ms | 39172 KB | Output is correct |
32 | Correct | 674 ms | 39204 KB | Output is correct |
33 | Correct | 677 ms | 39320 KB | Output is correct |
34 | Correct | 683 ms | 39344 KB | Output is correct |
35 | Correct | 698 ms | 39188 KB | Output is correct |
36 | Correct | 681 ms | 39188 KB | Output is correct |
37 | Correct | 673 ms | 39200 KB | Output is correct |
38 | Correct | 681 ms | 39204 KB | Output is correct |
39 | Correct | 685 ms | 39308 KB | Output is correct |
40 | Correct | 671 ms | 39200 KB | Output is correct |
41 | Correct | 674 ms | 39232 KB | Output is correct |
42 | Correct | 683 ms | 39340 KB | Output is correct |
43 | Correct | 686 ms | 39252 KB | Output is correct |
44 | Correct | 665 ms | 39136 KB | Output is correct |
45 | Correct | 672 ms | 39112 KB | Output is correct |
46 | Correct | 672 ms | 39144 KB | Output is correct |
47 | Correct | 671 ms | 39140 KB | Output is correct |
48 | Correct | 674 ms | 39316 KB | Output is correct |
49 | Correct | 669 ms | 39168 KB | Output is correct |
50 | Correct | 680 ms | 39112 KB | Output is correct |
51 | Correct | 664 ms | 39084 KB | Output is correct |
52 | Correct | 677 ms | 39128 KB | Output is correct |
53 | Correct | 664 ms | 39088 KB | Output is correct |
54 | Correct | 678 ms | 39224 KB | Output is correct |
55 | Correct | 682 ms | 39136 KB | Output is correct |
56 | Correct | 675 ms | 39396 KB | Output is correct |
57 | Correct | 683 ms | 39260 KB | Output is correct |
58 | Correct | 679 ms | 39140 KB | Output is correct |
59 | Correct | 667 ms | 39108 KB | Output is correct |
60 | Correct | 683 ms | 39260 KB | Output is correct |
61 | Correct | 680 ms | 39236 KB | Output is correct |
62 | Correct | 687 ms | 39232 KB | Output is correct |
63 | Correct | 678 ms | 39272 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 697 ms | 40664 KB | Output is correct |
2 | Correct | 693 ms | 40740 KB | Output is correct |
3 | Correct | 692 ms | 40688 KB | Output is correct |
4 | Correct | 676 ms | 40612 KB | Output is correct |
5 | Correct | 668 ms | 40532 KB | Output is correct |
6 | Correct | 686 ms | 40536 KB | Output is correct |
7 | Correct | 684 ms | 40596 KB | Output is correct |
8 | Correct | 690 ms | 40552 KB | Output is correct |
9 | Correct | 674 ms | 40556 KB | Output is correct |
10 | Correct | 686 ms | 40552 KB | Output is correct |
11 | Correct | 673 ms | 40556 KB | Output is correct |
12 | Correct | 680 ms | 40724 KB | Output is correct |
13 | Correct | 676 ms | 40580 KB | Output is correct |
14 | Correct | 674 ms | 40612 KB | Output is correct |
15 | Correct | 666 ms | 40592 KB | Output is correct |
16 | Correct | 689 ms | 40600 KB | Output is correct |
17 | Correct | 702 ms | 40604 KB | Output is correct |
18 | Correct | 703 ms | 40780 KB | Output is correct |
19 | Correct | 702 ms | 40540 KB | Output is correct |
20 | Correct | 684 ms | 40532 KB | Output is correct |
21 | Correct | 684 ms | 40512 KB | Output is correct |
22 | Correct | 696 ms | 39272 KB | Output is correct |
23 | Correct | 706 ms | 39336 KB | Output is correct |
24 | Correct | 671 ms | 39256 KB | Output is correct |
25 | Correct | 681 ms | 39164 KB | Output is correct |
26 | Correct | 674 ms | 39180 KB | Output is correct |
27 | Correct | 681 ms | 39240 KB | Output is correct |
28 | Correct | 694 ms | 39236 KB | Output is correct |
29 | Correct | 689 ms | 39356 KB | Output is correct |
30 | Correct | 678 ms | 39180 KB | Output is correct |
31 | Correct | 685 ms | 39172 KB | Output is correct |
32 | Correct | 674 ms | 39204 KB | Output is correct |
33 | Correct | 677 ms | 39320 KB | Output is correct |
34 | Correct | 683 ms | 39344 KB | Output is correct |
35 | Correct | 698 ms | 39188 KB | Output is correct |
36 | Correct | 681 ms | 39188 KB | Output is correct |
37 | Correct | 673 ms | 39200 KB | Output is correct |
38 | Correct | 681 ms | 39204 KB | Output is correct |
39 | Correct | 685 ms | 39308 KB | Output is correct |
40 | Correct | 671 ms | 39200 KB | Output is correct |
41 | Correct | 674 ms | 39232 KB | Output is correct |
42 | Correct | 683 ms | 39340 KB | Output is correct |
43 | Correct | 686 ms | 39252 KB | Output is correct |
44 | Correct | 665 ms | 39136 KB | Output is correct |
45 | Correct | 672 ms | 39112 KB | Output is correct |
46 | Correct | 672 ms | 39144 KB | Output is correct |
47 | Correct | 671 ms | 39140 KB | Output is correct |
48 | Correct | 674 ms | 39316 KB | Output is correct |
49 | Correct | 669 ms | 39168 KB | Output is correct |
50 | Correct | 680 ms | 39112 KB | Output is correct |
51 | Correct | 664 ms | 39084 KB | Output is correct |
52 | Correct | 677 ms | 39128 KB | Output is correct |
53 | Correct | 664 ms | 39088 KB | Output is correct |
54 | Correct | 678 ms | 39224 KB | Output is correct |
55 | Correct | 682 ms | 39136 KB | Output is correct |
56 | Correct | 675 ms | 39396 KB | Output is correct |
57 | Correct | 683 ms | 39260 KB | Output is correct |
58 | Correct | 679 ms | 39140 KB | Output is correct |
59 | Correct | 667 ms | 39108 KB | Output is correct |
60 | Correct | 683 ms | 39260 KB | Output is correct |
61 | Correct | 680 ms | 39236 KB | Output is correct |
62 | Correct | 687 ms | 39232 KB | Output is correct |
63 | Correct | 678 ms | 39272 KB | Output is correct |
64 | Correct | 677 ms | 39088 KB | Output is correct |
65 | Correct | 680 ms | 40000 KB | Output is correct |
66 | Correct | 730 ms | 39864 KB | Output is correct |
67 | Correct | 712 ms | 39964 KB | Output is correct |
68 | Correct | 720 ms | 39828 KB | Output is correct |
69 | Correct | 705 ms | 39876 KB | Output is correct |
70 | Correct | 738 ms | 39884 KB | Output is correct |
71 | Correct | 730 ms | 39904 KB | Output is correct |
72 | Correct | 747 ms | 39852 KB | Output is correct |
73 | Correct | 734 ms | 39856 KB | Output is correct |
74 | Correct | 727 ms | 39856 KB | Output is correct |
75 | Correct | 763 ms | 39880 KB | Output is correct |
76 | Correct | 763 ms | 39976 KB | Output is correct |
77 | Correct | 767 ms | 39976 KB | Output is correct |
78 | Correct | 740 ms | 39912 KB | Output is correct |
79 | Correct | 719 ms | 39872 KB | Output is correct |
80 | Correct | 727 ms | 39828 KB | Output is correct |
81 | Correct | 732 ms | 39948 KB | Output is correct |
82 | Correct | 734 ms | 39872 KB | Output is correct |
83 | Correct | 738 ms | 39944 KB | Output is correct |
84 | Correct | 734 ms | 39968 KB | Output is correct |