# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
898872 | 2024-01-05T08:22:41 Z | arashMLG | Cubeword (CEOI19_cubeword) | C++17 | 830 ms | 9248 KB |
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("sse4") typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const int N = 5e5 + 23; const int K = 26 + 26 +10; const ll mod = 998244353; const ll inf = 1e18; //#define F first #define S second #define pb push_back #define sz(x) ((int)x.size()) #define all(x) x.begin(),x.end() #define lc (v<<1) #define rc ((v<<1)|1) #define F(x) for(int x = 0; x < K; x++) #define debug(x) cout<<#x << " : " << x << endl; #define int ll int dp[K][K][K]; vector<string> s[11]; int cnt[K][K]; vector<pii> vec; int val[300]; int javab = 0; void solve(int len) { F(i) F(j) { cnt[i][j] = 0; F(k) dp[i][j][k] = 0; } sort(all(s[len])); s[len].resize(unique(all(s[len])) - s[len].begin()); for(string t : s[len]) { cnt[val[t[0]]][val[t.back()]] ++; } F(i) F(a) F(b) F(c) { (dp[a][b][c] += (1LL*cnt[i][a]*cnt[i][b]%mod*cnt[i][c] %mod)) %= mod; } int ans=0; F(a) F(b) F(c) F(d) { (ans += (dp[a][b][c] *dp[a][b][d]%mod*dp[a][c][d]%mod*dp[b][c][d])) %= mod; } (javab += ans) %=mod; } int32_t main() { cin.tie(nullptr)->sync_with_stdio(false); int x = 0; for(char c = 'a'; c<= 'z'; c++) { val[c] = x++; } for(char c = 'A'; c<= 'Z'; c++) { val[c] = x++; } for(char c = '0'; c <= '9'; c++) { val[c] = x ++; } int n; cin>>n; for(int i = 0 ;i < n ; i++){ string t; cin>>t; s[sz(t)].pb(t); reverse(all(t)); s[sz(t)].pb(t); } for(int i = 3; i <= 10; i ++) solve(i); cout<<javab%mod; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 806 ms | 8944 KB | Output is correct |
2 | Correct | 804 ms | 8880 KB | Output is correct |
3 | Correct | 802 ms | 8912 KB | Output is correct |
4 | Correct | 804 ms | 9036 KB | Output is correct |
5 | Correct | 810 ms | 9008 KB | Output is correct |
6 | Correct | 815 ms | 9164 KB | Output is correct |
7 | Correct | 803 ms | 8992 KB | Output is correct |
8 | Correct | 804 ms | 8936 KB | Output is correct |
9 | Correct | 811 ms | 8992 KB | Output is correct |
10 | Correct | 808 ms | 9236 KB | Output is correct |
11 | Correct | 807 ms | 9096 KB | Output is correct |
12 | Correct | 809 ms | 9020 KB | Output is correct |
13 | Correct | 808 ms | 8872 KB | Output is correct |
14 | Correct | 820 ms | 8976 KB | Output is correct |
15 | Correct | 818 ms | 8800 KB | Output is correct |
16 | Correct | 799 ms | 8840 KB | Output is correct |
17 | Correct | 812 ms | 8992 KB | Output is correct |
18 | Correct | 810 ms | 8872 KB | Output is correct |
19 | Correct | 803 ms | 8976 KB | Output is correct |
20 | Correct | 809 ms | 8996 KB | Output is correct |
21 | Correct | 807 ms | 9008 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 806 ms | 8944 KB | Output is correct |
2 | Correct | 804 ms | 8880 KB | Output is correct |
3 | Correct | 802 ms | 8912 KB | Output is correct |
4 | Correct | 804 ms | 9036 KB | Output is correct |
5 | Correct | 810 ms | 9008 KB | Output is correct |
6 | Correct | 815 ms | 9164 KB | Output is correct |
7 | Correct | 803 ms | 8992 KB | Output is correct |
8 | Correct | 804 ms | 8936 KB | Output is correct |
9 | Correct | 811 ms | 8992 KB | Output is correct |
10 | Correct | 808 ms | 9236 KB | Output is correct |
11 | Correct | 807 ms | 9096 KB | Output is correct |
12 | Correct | 809 ms | 9020 KB | Output is correct |
13 | Correct | 808 ms | 8872 KB | Output is correct |
14 | Correct | 820 ms | 8976 KB | Output is correct |
15 | Correct | 818 ms | 8800 KB | Output is correct |
16 | Correct | 799 ms | 8840 KB | Output is correct |
17 | Correct | 812 ms | 8992 KB | Output is correct |
18 | Correct | 810 ms | 8872 KB | Output is correct |
19 | Correct | 803 ms | 8976 KB | Output is correct |
20 | Correct | 809 ms | 8996 KB | Output is correct |
21 | Correct | 807 ms | 9008 KB | Output is correct |
22 | Correct | 824 ms | 8668 KB | Output is correct |
23 | Correct | 822 ms | 8776 KB | Output is correct |
24 | Correct | 814 ms | 8936 KB | Output is correct |
25 | Correct | 830 ms | 8912 KB | Output is correct |
26 | Correct | 826 ms | 8836 KB | Output is correct |
27 | Correct | 797 ms | 9248 KB | Output is correct |
28 | Correct | 810 ms | 8800 KB | Output is correct |
29 | Correct | 813 ms | 8644 KB | Output is correct |
30 | Correct | 821 ms | 8768 KB | Output is correct |
31 | Correct | 798 ms | 8808 KB | Output is correct |
32 | Correct | 811 ms | 8784 KB | Output is correct |
33 | Correct | 796 ms | 8764 KB | Output is correct |
34 | Correct | 803 ms | 8856 KB | Output is correct |
35 | Correct | 797 ms | 8996 KB | Output is correct |
36 | Correct | 805 ms | 8848 KB | Output is correct |
37 | Correct | 818 ms | 8552 KB | Output is correct |
38 | Correct | 804 ms | 8908 KB | Output is correct |
39 | Correct | 800 ms | 8900 KB | Output is correct |
40 | Correct | 805 ms | 8828 KB | Output is correct |
41 | Correct | 813 ms | 8936 KB | Output is correct |
42 | Correct | 803 ms | 8760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 806 ms | 8944 KB | Output is correct |
2 | Correct | 804 ms | 8880 KB | Output is correct |
3 | Correct | 802 ms | 8912 KB | Output is correct |
4 | Correct | 804 ms | 9036 KB | Output is correct |
5 | Correct | 810 ms | 9008 KB | Output is correct |
6 | Correct | 815 ms | 9164 KB | Output is correct |
7 | Correct | 803 ms | 8992 KB | Output is correct |
8 | Correct | 804 ms | 8936 KB | Output is correct |
9 | Correct | 811 ms | 8992 KB | Output is correct |
10 | Correct | 808 ms | 9236 KB | Output is correct |
11 | Correct | 807 ms | 9096 KB | Output is correct |
12 | Correct | 809 ms | 9020 KB | Output is correct |
13 | Correct | 808 ms | 8872 KB | Output is correct |
14 | Correct | 820 ms | 8976 KB | Output is correct |
15 | Correct | 818 ms | 8800 KB | Output is correct |
16 | Correct | 799 ms | 8840 KB | Output is correct |
17 | Correct | 812 ms | 8992 KB | Output is correct |
18 | Correct | 810 ms | 8872 KB | Output is correct |
19 | Correct | 803 ms | 8976 KB | Output is correct |
20 | Correct | 809 ms | 8996 KB | Output is correct |
21 | Correct | 807 ms | 9008 KB | Output is correct |
22 | Correct | 824 ms | 8668 KB | Output is correct |
23 | Correct | 822 ms | 8776 KB | Output is correct |
24 | Correct | 814 ms | 8936 KB | Output is correct |
25 | Correct | 830 ms | 8912 KB | Output is correct |
26 | Correct | 826 ms | 8836 KB | Output is correct |
27 | Correct | 797 ms | 9248 KB | Output is correct |
28 | Correct | 810 ms | 8800 KB | Output is correct |
29 | Correct | 813 ms | 8644 KB | Output is correct |
30 | Correct | 821 ms | 8768 KB | Output is correct |
31 | Correct | 798 ms | 8808 KB | Output is correct |
32 | Correct | 811 ms | 8784 KB | Output is correct |
33 | Correct | 796 ms | 8764 KB | Output is correct |
34 | Correct | 803 ms | 8856 KB | Output is correct |
35 | Correct | 797 ms | 8996 KB | Output is correct |
36 | Correct | 805 ms | 8848 KB | Output is correct |
37 | Correct | 818 ms | 8552 KB | Output is correct |
38 | Correct | 804 ms | 8908 KB | Output is correct |
39 | Correct | 800 ms | 8900 KB | Output is correct |
40 | Correct | 805 ms | 8828 KB | Output is correct |
41 | Correct | 813 ms | 8936 KB | Output is correct |
42 | Correct | 803 ms | 8760 KB | Output is correct |
43 | Correct | 807 ms | 8644 KB | Output is correct |
44 | Correct | 804 ms | 8724 KB | Output is correct |
45 | Correct | 806 ms | 8636 KB | Output is correct |
46 | Correct | 808 ms | 8760 KB | Output is correct |
47 | Correct | 802 ms | 8800 KB | Output is correct |
48 | Correct | 812 ms | 9152 KB | Output is correct |
49 | Correct | 803 ms | 9156 KB | Output is correct |
50 | Correct | 799 ms | 9168 KB | Output is correct |
51 | Correct | 813 ms | 8876 KB | Output is correct |
52 | Correct | 805 ms | 8724 KB | Output is correct |
53 | Correct | 805 ms | 8592 KB | Output is correct |
54 | Correct | 804 ms | 8848 KB | Output is correct |
55 | Correct | 802 ms | 9232 KB | Output is correct |
56 | Correct | 813 ms | 8776 KB | Output is correct |
57 | Correct | 808 ms | 9036 KB | Output is correct |
58 | Correct | 823 ms | 9144 KB | Output is correct |
59 | Correct | 821 ms | 9028 KB | Output is correct |
60 | Correct | 801 ms | 9016 KB | Output is correct |
61 | Correct | 813 ms | 8768 KB | Output is correct |
62 | Correct | 813 ms | 9224 KB | Output is correct |
63 | Correct | 801 ms | 9024 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 806 ms | 8944 KB | Output is correct |
2 | Correct | 804 ms | 8880 KB | Output is correct |
3 | Correct | 802 ms | 8912 KB | Output is correct |
4 | Correct | 804 ms | 9036 KB | Output is correct |
5 | Correct | 810 ms | 9008 KB | Output is correct |
6 | Correct | 815 ms | 9164 KB | Output is correct |
7 | Correct | 803 ms | 8992 KB | Output is correct |
8 | Correct | 804 ms | 8936 KB | Output is correct |
9 | Correct | 811 ms | 8992 KB | Output is correct |
10 | Correct | 808 ms | 9236 KB | Output is correct |
11 | Correct | 807 ms | 9096 KB | Output is correct |
12 | Correct | 809 ms | 9020 KB | Output is correct |
13 | Correct | 808 ms | 8872 KB | Output is correct |
14 | Correct | 820 ms | 8976 KB | Output is correct |
15 | Correct | 818 ms | 8800 KB | Output is correct |
16 | Correct | 799 ms | 8840 KB | Output is correct |
17 | Correct | 812 ms | 8992 KB | Output is correct |
18 | Correct | 810 ms | 8872 KB | Output is correct |
19 | Correct | 803 ms | 8976 KB | Output is correct |
20 | Correct | 809 ms | 8996 KB | Output is correct |
21 | Correct | 807 ms | 9008 KB | Output is correct |
22 | Correct | 824 ms | 8668 KB | Output is correct |
23 | Correct | 822 ms | 8776 KB | Output is correct |
24 | Correct | 814 ms | 8936 KB | Output is correct |
25 | Correct | 830 ms | 8912 KB | Output is correct |
26 | Correct | 826 ms | 8836 KB | Output is correct |
27 | Correct | 797 ms | 9248 KB | Output is correct |
28 | Correct | 810 ms | 8800 KB | Output is correct |
29 | Correct | 813 ms | 8644 KB | Output is correct |
30 | Correct | 821 ms | 8768 KB | Output is correct |
31 | Correct | 798 ms | 8808 KB | Output is correct |
32 | Correct | 811 ms | 8784 KB | Output is correct |
33 | Correct | 796 ms | 8764 KB | Output is correct |
34 | Correct | 803 ms | 8856 KB | Output is correct |
35 | Correct | 797 ms | 8996 KB | Output is correct |
36 | Correct | 805 ms | 8848 KB | Output is correct |
37 | Correct | 818 ms | 8552 KB | Output is correct |
38 | Correct | 804 ms | 8908 KB | Output is correct |
39 | Correct | 800 ms | 8900 KB | Output is correct |
40 | Correct | 805 ms | 8828 KB | Output is correct |
41 | Correct | 813 ms | 8936 KB | Output is correct |
42 | Correct | 803 ms | 8760 KB | Output is correct |
43 | Correct | 807 ms | 8644 KB | Output is correct |
44 | Correct | 804 ms | 8724 KB | Output is correct |
45 | Correct | 806 ms | 8636 KB | Output is correct |
46 | Correct | 808 ms | 8760 KB | Output is correct |
47 | Correct | 802 ms | 8800 KB | Output is correct |
48 | Correct | 812 ms | 9152 KB | Output is correct |
49 | Correct | 803 ms | 9156 KB | Output is correct |
50 | Correct | 799 ms | 9168 KB | Output is correct |
51 | Correct | 813 ms | 8876 KB | Output is correct |
52 | Correct | 805 ms | 8724 KB | Output is correct |
53 | Correct | 805 ms | 8592 KB | Output is correct |
54 | Correct | 804 ms | 8848 KB | Output is correct |
55 | Correct | 802 ms | 9232 KB | Output is correct |
56 | Correct | 813 ms | 8776 KB | Output is correct |
57 | Correct | 808 ms | 9036 KB | Output is correct |
58 | Correct | 823 ms | 9144 KB | Output is correct |
59 | Correct | 821 ms | 9028 KB | Output is correct |
60 | Correct | 801 ms | 9016 KB | Output is correct |
61 | Correct | 813 ms | 8768 KB | Output is correct |
62 | Correct | 813 ms | 9224 KB | Output is correct |
63 | Correct | 801 ms | 9024 KB | Output is correct |
64 | Correct | 798 ms | 8888 KB | Output is correct |
65 | Correct | 812 ms | 9028 KB | Output is correct |
66 | Correct | 811 ms | 8668 KB | Output is correct |
67 | Correct | 800 ms | 8712 KB | Output is correct |
68 | Correct | 803 ms | 8652 KB | Output is correct |
69 | Correct | 801 ms | 8896 KB | Output is correct |
70 | Correct | 800 ms | 8900 KB | Output is correct |
71 | Correct | 807 ms | 8792 KB | Output is correct |
72 | Correct | 803 ms | 9024 KB | Output is correct |
73 | Correct | 805 ms | 8896 KB | Output is correct |
74 | Correct | 798 ms | 9196 KB | Output is correct |
75 | Correct | 812 ms | 8980 KB | Output is correct |
76 | Correct | 803 ms | 8916 KB | Output is correct |
77 | Correct | 799 ms | 8612 KB | Output is correct |
78 | Correct | 816 ms | 8760 KB | Output is correct |
79 | Correct | 811 ms | 8768 KB | Output is correct |
80 | Correct | 806 ms | 9028 KB | Output is correct |
81 | Correct | 799 ms | 9168 KB | Output is correct |
82 | Correct | 801 ms | 9232 KB | Output is correct |
83 | Correct | 813 ms | 8896 KB | Output is correct |
84 | Correct | 799 ms | 9152 KB | Output is correct |