답안 #1038305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1038305 2024-07-29T16:02:35 Z vjudge1 Cubeword (CEOI19_cubeword) C++17
100 / 100
276 ms 19140 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    
    long long int M = 998244353;
    map<char, int> m;
    for(int i=0; i<26; i++) m['a'+(char)i]=i;
    for(int i=0; i<26; i++) m['A'+(char)i]=i+26;
    for(int i=0; i<10; i++) m['0'+(char)i]=i+52;
    map<string, int> omega;
    
    long long int U[10][62][62];
    for(int k=0; k<10; k++) for(int i=0; i<62; i++) for(int j=0; j<62; j++) U[k][i][j]=0;
    for(int i=0; i<n; i++){
        string s;
        cin>>s;
        string t="";
        int l=s.size()-1;
        for(int i=0; i<=l; i++){
            t.push_back(s[l-i]);
        }
        if(omega[s]==0){
            omega[s]++;
            U[l][m[s[0]]][m[s[l]]]++;
        }
        if(omega[t]==0){
            omega[t]++;
            U[l][m[t[0]]][m[t[l]]]++;
        }
    }
    long long int H[62][62][62];
    long long int ans=0;
    for(int v=2; v<10; v++){
        for(int k=0; k<62; k++) for(int i=k; i<62; i++) for(int j=i; j<62; j++) H[k][i][j]=0;
        for(int i=0; i<62; i++){
            for(int j=i; j<62; j++){
                for(int k=j; k<62; k++){
                    for(int l=0; l<62; l++){
                        H[i][j][k] = (H[i][j][k]+(((U[v][i][l]*U[v][j][l])%M)*U[v][k][l]))%M;
                    }
                }
            }
        }
        for(int i=0; i<62; i++){
            for(int j=i; j<62; j++){
                for(int k=j; k<62; k++){
                    for(int l=k; l<62; l++){
                        long long int V = (((H[i][j][k]*H[i][j][l])%M)*((H[i][k][l]*H[j][k][l])%M))%M;
                        if(i!=j){
                            V*=4;
                            if(j!=k){
                                V*=3;
                                if(k!=l) V*=2;
                            }else if(j!=l){
                                V*=3;
                            }
                        }else if(j!=k){
                            if(l!=k){
                                V*=12;
                            }else{
                                V*=6;
                            }
                        }else if(k!=l){
                            V*=4;
                        }
                        ans+=V;
                        ans%=M;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 16976 KB Output is correct
2 Correct 219 ms 17760 KB Output is correct
3 Correct 235 ms 17748 KB Output is correct
4 Correct 229 ms 17748 KB Output is correct
5 Correct 237 ms 17836 KB Output is correct
6 Correct 241 ms 17748 KB Output is correct
7 Correct 238 ms 17748 KB Output is correct
8 Correct 233 ms 17876 KB Output is correct
9 Correct 238 ms 17748 KB Output is correct
10 Correct 237 ms 17824 KB Output is correct
11 Correct 231 ms 17748 KB Output is correct
12 Correct 230 ms 17748 KB Output is correct
13 Correct 231 ms 17948 KB Output is correct
14 Correct 240 ms 17916 KB Output is correct
15 Correct 232 ms 17924 KB Output is correct
16 Correct 234 ms 17720 KB Output is correct
17 Correct 243 ms 17748 KB Output is correct
18 Correct 236 ms 17748 KB Output is correct
19 Correct 252 ms 18124 KB Output is correct
20 Correct 233 ms 17748 KB Output is correct
21 Correct 262 ms 17688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 16976 KB Output is correct
2 Correct 219 ms 17760 KB Output is correct
3 Correct 235 ms 17748 KB Output is correct
4 Correct 229 ms 17748 KB Output is correct
5 Correct 237 ms 17836 KB Output is correct
6 Correct 241 ms 17748 KB Output is correct
7 Correct 238 ms 17748 KB Output is correct
8 Correct 233 ms 17876 KB Output is correct
9 Correct 238 ms 17748 KB Output is correct
10 Correct 237 ms 17824 KB Output is correct
11 Correct 231 ms 17748 KB Output is correct
12 Correct 230 ms 17748 KB Output is correct
13 Correct 231 ms 17948 KB Output is correct
14 Correct 240 ms 17916 KB Output is correct
15 Correct 232 ms 17924 KB Output is correct
16 Correct 234 ms 17720 KB Output is correct
17 Correct 243 ms 17748 KB Output is correct
18 Correct 236 ms 17748 KB Output is correct
19 Correct 252 ms 18124 KB Output is correct
20 Correct 233 ms 17748 KB Output is correct
21 Correct 262 ms 17688 KB Output is correct
22 Correct 233 ms 18360 KB Output is correct
23 Correct 222 ms 18516 KB Output is correct
24 Correct 232 ms 18344 KB Output is correct
25 Correct 240 ms 18360 KB Output is correct
26 Correct 229 ms 18260 KB Output is correct
27 Correct 245 ms 18260 KB Output is correct
28 Correct 232 ms 18320 KB Output is correct
29 Correct 235 ms 18516 KB Output is correct
30 Correct 237 ms 18260 KB Output is correct
31 Correct 241 ms 18516 KB Output is correct
32 Correct 225 ms 18260 KB Output is correct
33 Correct 239 ms 18260 KB Output is correct
34 Correct 228 ms 18260 KB Output is correct
35 Correct 240 ms 18484 KB Output is correct
36 Correct 231 ms 18520 KB Output is correct
37 Correct 238 ms 18264 KB Output is correct
38 Correct 253 ms 18504 KB Output is correct
39 Correct 256 ms 18524 KB Output is correct
40 Correct 267 ms 18264 KB Output is correct
41 Correct 237 ms 18384 KB Output is correct
42 Correct 254 ms 18424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 16976 KB Output is correct
2 Correct 219 ms 17760 KB Output is correct
3 Correct 235 ms 17748 KB Output is correct
4 Correct 229 ms 17748 KB Output is correct
5 Correct 237 ms 17836 KB Output is correct
6 Correct 241 ms 17748 KB Output is correct
7 Correct 238 ms 17748 KB Output is correct
8 Correct 233 ms 17876 KB Output is correct
9 Correct 238 ms 17748 KB Output is correct
10 Correct 237 ms 17824 KB Output is correct
11 Correct 231 ms 17748 KB Output is correct
12 Correct 230 ms 17748 KB Output is correct
13 Correct 231 ms 17948 KB Output is correct
14 Correct 240 ms 17916 KB Output is correct
15 Correct 232 ms 17924 KB Output is correct
16 Correct 234 ms 17720 KB Output is correct
17 Correct 243 ms 17748 KB Output is correct
18 Correct 236 ms 17748 KB Output is correct
19 Correct 252 ms 18124 KB Output is correct
20 Correct 233 ms 17748 KB Output is correct
21 Correct 262 ms 17688 KB Output is correct
22 Correct 233 ms 18360 KB Output is correct
23 Correct 222 ms 18516 KB Output is correct
24 Correct 232 ms 18344 KB Output is correct
25 Correct 240 ms 18360 KB Output is correct
26 Correct 229 ms 18260 KB Output is correct
27 Correct 245 ms 18260 KB Output is correct
28 Correct 232 ms 18320 KB Output is correct
29 Correct 235 ms 18516 KB Output is correct
30 Correct 237 ms 18260 KB Output is correct
31 Correct 241 ms 18516 KB Output is correct
32 Correct 225 ms 18260 KB Output is correct
33 Correct 239 ms 18260 KB Output is correct
34 Correct 228 ms 18260 KB Output is correct
35 Correct 240 ms 18484 KB Output is correct
36 Correct 231 ms 18520 KB Output is correct
37 Correct 238 ms 18264 KB Output is correct
38 Correct 253 ms 18504 KB Output is correct
39 Correct 256 ms 18524 KB Output is correct
40 Correct 267 ms 18264 KB Output is correct
41 Correct 237 ms 18384 KB Output is correct
42 Correct 254 ms 18424 KB Output is correct
43 Correct 249 ms 18556 KB Output is correct
44 Correct 238 ms 18612 KB Output is correct
45 Correct 244 ms 18516 KB Output is correct
46 Correct 235 ms 18592 KB Output is correct
47 Correct 239 ms 18516 KB Output is correct
48 Correct 259 ms 18600 KB Output is correct
49 Correct 276 ms 18484 KB Output is correct
50 Correct 230 ms 18516 KB Output is correct
51 Correct 242 ms 18480 KB Output is correct
52 Correct 256 ms 18692 KB Output is correct
53 Correct 236 ms 18516 KB Output is correct
54 Correct 242 ms 18516 KB Output is correct
55 Correct 234 ms 18512 KB Output is correct
56 Correct 238 ms 18856 KB Output is correct
57 Correct 226 ms 18516 KB Output is correct
58 Correct 225 ms 18516 KB Output is correct
59 Correct 239 ms 18516 KB Output is correct
60 Correct 245 ms 18448 KB Output is correct
61 Correct 253 ms 18772 KB Output is correct
62 Correct 254 ms 18588 KB Output is correct
63 Correct 247 ms 18516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 16976 KB Output is correct
2 Correct 219 ms 17760 KB Output is correct
3 Correct 235 ms 17748 KB Output is correct
4 Correct 229 ms 17748 KB Output is correct
5 Correct 237 ms 17836 KB Output is correct
6 Correct 241 ms 17748 KB Output is correct
7 Correct 238 ms 17748 KB Output is correct
8 Correct 233 ms 17876 KB Output is correct
9 Correct 238 ms 17748 KB Output is correct
10 Correct 237 ms 17824 KB Output is correct
11 Correct 231 ms 17748 KB Output is correct
12 Correct 230 ms 17748 KB Output is correct
13 Correct 231 ms 17948 KB Output is correct
14 Correct 240 ms 17916 KB Output is correct
15 Correct 232 ms 17924 KB Output is correct
16 Correct 234 ms 17720 KB Output is correct
17 Correct 243 ms 17748 KB Output is correct
18 Correct 236 ms 17748 KB Output is correct
19 Correct 252 ms 18124 KB Output is correct
20 Correct 233 ms 17748 KB Output is correct
21 Correct 262 ms 17688 KB Output is correct
22 Correct 233 ms 18360 KB Output is correct
23 Correct 222 ms 18516 KB Output is correct
24 Correct 232 ms 18344 KB Output is correct
25 Correct 240 ms 18360 KB Output is correct
26 Correct 229 ms 18260 KB Output is correct
27 Correct 245 ms 18260 KB Output is correct
28 Correct 232 ms 18320 KB Output is correct
29 Correct 235 ms 18516 KB Output is correct
30 Correct 237 ms 18260 KB Output is correct
31 Correct 241 ms 18516 KB Output is correct
32 Correct 225 ms 18260 KB Output is correct
33 Correct 239 ms 18260 KB Output is correct
34 Correct 228 ms 18260 KB Output is correct
35 Correct 240 ms 18484 KB Output is correct
36 Correct 231 ms 18520 KB Output is correct
37 Correct 238 ms 18264 KB Output is correct
38 Correct 253 ms 18504 KB Output is correct
39 Correct 256 ms 18524 KB Output is correct
40 Correct 267 ms 18264 KB Output is correct
41 Correct 237 ms 18384 KB Output is correct
42 Correct 254 ms 18424 KB Output is correct
43 Correct 249 ms 18556 KB Output is correct
44 Correct 238 ms 18612 KB Output is correct
45 Correct 244 ms 18516 KB Output is correct
46 Correct 235 ms 18592 KB Output is correct
47 Correct 239 ms 18516 KB Output is correct
48 Correct 259 ms 18600 KB Output is correct
49 Correct 276 ms 18484 KB Output is correct
50 Correct 230 ms 18516 KB Output is correct
51 Correct 242 ms 18480 KB Output is correct
52 Correct 256 ms 18692 KB Output is correct
53 Correct 236 ms 18516 KB Output is correct
54 Correct 242 ms 18516 KB Output is correct
55 Correct 234 ms 18512 KB Output is correct
56 Correct 238 ms 18856 KB Output is correct
57 Correct 226 ms 18516 KB Output is correct
58 Correct 225 ms 18516 KB Output is correct
59 Correct 239 ms 18516 KB Output is correct
60 Correct 245 ms 18448 KB Output is correct
61 Correct 253 ms 18772 KB Output is correct
62 Correct 254 ms 18588 KB Output is correct
63 Correct 247 ms 18516 KB Output is correct
64 Correct 248 ms 18772 KB Output is correct
65 Correct 235 ms 18772 KB Output is correct
66 Correct 245 ms 18924 KB Output is correct
67 Correct 272 ms 18704 KB Output is correct
68 Correct 255 ms 18800 KB Output is correct
69 Correct 247 ms 18772 KB Output is correct
70 Correct 252 ms 18896 KB Output is correct
71 Correct 246 ms 18680 KB Output is correct
72 Correct 242 ms 18936 KB Output is correct
73 Correct 253 ms 18772 KB Output is correct
74 Correct 263 ms 19140 KB Output is correct
75 Correct 245 ms 18772 KB Output is correct
76 Correct 223 ms 18924 KB Output is correct
77 Correct 256 ms 18812 KB Output is correct
78 Correct 246 ms 18772 KB Output is correct
79 Correct 235 ms 18772 KB Output is correct
80 Correct 239 ms 18752 KB Output is correct
81 Correct 226 ms 18772 KB Output is correct
82 Correct 268 ms 18772 KB Output is correct
83 Correct 241 ms 18776 KB Output is correct
84 Correct 232 ms 18736 KB Output is correct