답안 #898849

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898849 2024-01-05T08:02:44 Z Iliya_ Cubeword (CEOI19_cubeword) C++14
84 / 100
1100 ms 8260 KB
//IN THE NAME OF GOD
#include<bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
#define endl        '\n'
#define F           first
#define S           second
#define pii         pair<int,int>
#define all(x)      x.begin(),x.end()
#define pb          push_back
#define fast_io     ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define file_io     freopen("input.in" , "r" , stdin) ; freopen("output.out" , "w" , stdout);
using namespace std;
typedef long long ll; 
typedef long double dll;

const int N = 62, NN = 11, mod = 998244353; 
int hav[NN][N][N], havi[NN], can[NN][N], dp[N][N][N];
vector<string> vec[NN];

inline int f(char c){
     if (int(c) <= 57) return (int(c)-48);
     else if (int(c) <= 90) return (int(c)-65+10); 
     else return (int(c)-97+36);
}

inline char ff(int x){
     if (x < 10) return char(x+48);
     else if (x < 36) return char(x+65-10);
     else return char(x+97-36);
}

int32_t main(){
     fast_io;

     int n; cin >> n;
     string s, ss; int siz;  
     for(int i=1; i<=n; i++){
          cin >> s; ss = s;
          siz = s.size(); 
          havi[siz] = 1;
          vec[siz].pb(s); 
          reverse(all(ss));
          if (ss != s) vec[siz].pb(ss);   
     }
     for(int i=3; i<=10; i++){
          sort(all(vec[i]));
          for(int j=0; j<int(vec[i].size()); j++){
               if (j != 0 && vec[i][j] == vec[i][j-1]) continue;
               can[i][f(vec[i][j][0])] = 1;
               hav[i][f(vec[i][j][0])][f(vec[i][j].back())]++;
          }    
     }
     ll ans = 0, tmp;
     for(int i=3; i<=10; i++){
          if (!havi[i]) continue; 
          memset(dp,0,sizeof dp);
          for(int s1 = 0; s1<N; s1++){
               if (!can[i][s1]) continue; 
               for(int s2 = 0; s2<N; s2++){
                    if (!can[i][s2]) continue; 
                    for(int s3 = 0; s3 < N; s3++){
                         if (!can[i][s3]) continue; 
                         for(int put=0; put<N; put++) dp[s1][s2][s3] = (dp[s1][s2][s3]+1ll*hav[i][s1][put]*hav[i][s2][put]*hav[i][s3][put]%mod)%mod;
                    }
               }
          }
          for(int s1 = 0; s1<N; s1++){
               if (!can[i][s1]) continue; 
               for(int s2=0; s2<N; s2++){
                    if (!can[i][s2]) continue; 
                    for(int s3=0; s3<N; s3++){
                         if (!can[i][s3]) continue; 
                         for(int s4=0; s4<N; s4++){
                              if (!can[i][s4]) continue; 
                              tmp = 1ll*dp[s1][s2][s3]*dp[s1][s2][s4]%mod*dp[s1][s3][s4]%mod*dp[s2][s3][s4]%mod;
                              ans = (ans+tmp)%mod;
                         }
                    }
               }
          }
     }
     cout << ans << endl;

     return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 7908 KB Output is correct
2 Correct 44 ms 7908 KB Output is correct
3 Correct 42 ms 7824 KB Output is correct
4 Correct 44 ms 8012 KB Output is correct
5 Correct 43 ms 8008 KB Output is correct
6 Correct 44 ms 8076 KB Output is correct
7 Correct 44 ms 7924 KB Output is correct
8 Correct 43 ms 7844 KB Output is correct
9 Correct 44 ms 7884 KB Output is correct
10 Correct 43 ms 7956 KB Output is correct
11 Correct 42 ms 8072 KB Output is correct
12 Correct 43 ms 8092 KB Output is correct
13 Correct 43 ms 7832 KB Output is correct
14 Correct 44 ms 7692 KB Output is correct
15 Correct 43 ms 7908 KB Output is correct
16 Correct 43 ms 7804 KB Output is correct
17 Correct 43 ms 7920 KB Output is correct
18 Correct 42 ms 7780 KB Output is correct
19 Correct 43 ms 7908 KB Output is correct
20 Correct 43 ms 7904 KB Output is correct
21 Correct 43 ms 7928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 7908 KB Output is correct
2 Correct 44 ms 7908 KB Output is correct
3 Correct 42 ms 7824 KB Output is correct
4 Correct 44 ms 8012 KB Output is correct
5 Correct 43 ms 8008 KB Output is correct
6 Correct 44 ms 8076 KB Output is correct
7 Correct 44 ms 7924 KB Output is correct
8 Correct 43 ms 7844 KB Output is correct
9 Correct 44 ms 7884 KB Output is correct
10 Correct 43 ms 7956 KB Output is correct
11 Correct 42 ms 8072 KB Output is correct
12 Correct 43 ms 8092 KB Output is correct
13 Correct 43 ms 7832 KB Output is correct
14 Correct 44 ms 7692 KB Output is correct
15 Correct 43 ms 7908 KB Output is correct
16 Correct 43 ms 7804 KB Output is correct
17 Correct 43 ms 7920 KB Output is correct
18 Correct 42 ms 7780 KB Output is correct
19 Correct 43 ms 7908 KB Output is correct
20 Correct 43 ms 7904 KB Output is correct
21 Correct 43 ms 7928 KB Output is correct
22 Correct 53 ms 7708 KB Output is correct
23 Correct 53 ms 7768 KB Output is correct
24 Correct 52 ms 7764 KB Output is correct
25 Correct 53 ms 7816 KB Output is correct
26 Correct 53 ms 7848 KB Output is correct
27 Correct 52 ms 8096 KB Output is correct
28 Correct 52 ms 7776 KB Output is correct
29 Correct 53 ms 7856 KB Output is correct
30 Correct 53 ms 7696 KB Output is correct
31 Correct 52 ms 7776 KB Output is correct
32 Correct 53 ms 7764 KB Output is correct
33 Correct 53 ms 7696 KB Output is correct
34 Correct 53 ms 7904 KB Output is correct
35 Correct 52 ms 7712 KB Output is correct
36 Correct 53 ms 7820 KB Output is correct
37 Correct 53 ms 7644 KB Output is correct
38 Correct 52 ms 7816 KB Output is correct
39 Correct 53 ms 8252 KB Output is correct
40 Correct 52 ms 7752 KB Output is correct
41 Correct 52 ms 7836 KB Output is correct
42 Correct 53 ms 7628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 7908 KB Output is correct
2 Correct 44 ms 7908 KB Output is correct
3 Correct 42 ms 7824 KB Output is correct
4 Correct 44 ms 8012 KB Output is correct
5 Correct 43 ms 8008 KB Output is correct
6 Correct 44 ms 8076 KB Output is correct
7 Correct 44 ms 7924 KB Output is correct
8 Correct 43 ms 7844 KB Output is correct
9 Correct 44 ms 7884 KB Output is correct
10 Correct 43 ms 7956 KB Output is correct
11 Correct 42 ms 8072 KB Output is correct
12 Correct 43 ms 8092 KB Output is correct
13 Correct 43 ms 7832 KB Output is correct
14 Correct 44 ms 7692 KB Output is correct
15 Correct 43 ms 7908 KB Output is correct
16 Correct 43 ms 7804 KB Output is correct
17 Correct 43 ms 7920 KB Output is correct
18 Correct 42 ms 7780 KB Output is correct
19 Correct 43 ms 7908 KB Output is correct
20 Correct 43 ms 7904 KB Output is correct
21 Correct 43 ms 7928 KB Output is correct
22 Correct 53 ms 7708 KB Output is correct
23 Correct 53 ms 7768 KB Output is correct
24 Correct 52 ms 7764 KB Output is correct
25 Correct 53 ms 7816 KB Output is correct
26 Correct 53 ms 7848 KB Output is correct
27 Correct 52 ms 8096 KB Output is correct
28 Correct 52 ms 7776 KB Output is correct
29 Correct 53 ms 7856 KB Output is correct
30 Correct 53 ms 7696 KB Output is correct
31 Correct 52 ms 7776 KB Output is correct
32 Correct 53 ms 7764 KB Output is correct
33 Correct 53 ms 7696 KB Output is correct
34 Correct 53 ms 7904 KB Output is correct
35 Correct 52 ms 7712 KB Output is correct
36 Correct 53 ms 7820 KB Output is correct
37 Correct 53 ms 7644 KB Output is correct
38 Correct 52 ms 7816 KB Output is correct
39 Correct 53 ms 8252 KB Output is correct
40 Correct 52 ms 7752 KB Output is correct
41 Correct 52 ms 7836 KB Output is correct
42 Correct 53 ms 7628 KB Output is correct
43 Correct 155 ms 7920 KB Output is correct
44 Correct 156 ms 7672 KB Output is correct
45 Correct 164 ms 8108 KB Output is correct
46 Correct 155 ms 7684 KB Output is correct
47 Correct 155 ms 7800 KB Output is correct
48 Correct 154 ms 8132 KB Output is correct
49 Correct 155 ms 7696 KB Output is correct
50 Correct 158 ms 8096 KB Output is correct
51 Correct 154 ms 8092 KB Output is correct
52 Correct 157 ms 7932 KB Output is correct
53 Correct 154 ms 7808 KB Output is correct
54 Correct 158 ms 8064 KB Output is correct
55 Correct 155 ms 8204 KB Output is correct
56 Correct 158 ms 7920 KB Output is correct
57 Correct 155 ms 8072 KB Output is correct
58 Correct 155 ms 8260 KB Output is correct
59 Correct 158 ms 8152 KB Output is correct
60 Correct 157 ms 8236 KB Output is correct
61 Correct 156 ms 7776 KB Output is correct
62 Correct 156 ms 7948 KB Output is correct
63 Correct 155 ms 8168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 7908 KB Output is correct
2 Correct 44 ms 7908 KB Output is correct
3 Correct 42 ms 7824 KB Output is correct
4 Correct 44 ms 8012 KB Output is correct
5 Correct 43 ms 8008 KB Output is correct
6 Correct 44 ms 8076 KB Output is correct
7 Correct 44 ms 7924 KB Output is correct
8 Correct 43 ms 7844 KB Output is correct
9 Correct 44 ms 7884 KB Output is correct
10 Correct 43 ms 7956 KB Output is correct
11 Correct 42 ms 8072 KB Output is correct
12 Correct 43 ms 8092 KB Output is correct
13 Correct 43 ms 7832 KB Output is correct
14 Correct 44 ms 7692 KB Output is correct
15 Correct 43 ms 7908 KB Output is correct
16 Correct 43 ms 7804 KB Output is correct
17 Correct 43 ms 7920 KB Output is correct
18 Correct 42 ms 7780 KB Output is correct
19 Correct 43 ms 7908 KB Output is correct
20 Correct 43 ms 7904 KB Output is correct
21 Correct 43 ms 7928 KB Output is correct
22 Correct 53 ms 7708 KB Output is correct
23 Correct 53 ms 7768 KB Output is correct
24 Correct 52 ms 7764 KB Output is correct
25 Correct 53 ms 7816 KB Output is correct
26 Correct 53 ms 7848 KB Output is correct
27 Correct 52 ms 8096 KB Output is correct
28 Correct 52 ms 7776 KB Output is correct
29 Correct 53 ms 7856 KB Output is correct
30 Correct 53 ms 7696 KB Output is correct
31 Correct 52 ms 7776 KB Output is correct
32 Correct 53 ms 7764 KB Output is correct
33 Correct 53 ms 7696 KB Output is correct
34 Correct 53 ms 7904 KB Output is correct
35 Correct 52 ms 7712 KB Output is correct
36 Correct 53 ms 7820 KB Output is correct
37 Correct 53 ms 7644 KB Output is correct
38 Correct 52 ms 7816 KB Output is correct
39 Correct 53 ms 8252 KB Output is correct
40 Correct 52 ms 7752 KB Output is correct
41 Correct 52 ms 7836 KB Output is correct
42 Correct 53 ms 7628 KB Output is correct
43 Correct 155 ms 7920 KB Output is correct
44 Correct 156 ms 7672 KB Output is correct
45 Correct 164 ms 8108 KB Output is correct
46 Correct 155 ms 7684 KB Output is correct
47 Correct 155 ms 7800 KB Output is correct
48 Correct 154 ms 8132 KB Output is correct
49 Correct 155 ms 7696 KB Output is correct
50 Correct 158 ms 8096 KB Output is correct
51 Correct 154 ms 8092 KB Output is correct
52 Correct 157 ms 7932 KB Output is correct
53 Correct 154 ms 7808 KB Output is correct
54 Correct 158 ms 8064 KB Output is correct
55 Correct 155 ms 8204 KB Output is correct
56 Correct 158 ms 7920 KB Output is correct
57 Correct 155 ms 8072 KB Output is correct
58 Correct 155 ms 8260 KB Output is correct
59 Correct 158 ms 8152 KB Output is correct
60 Correct 157 ms 8236 KB Output is correct
61 Correct 156 ms 7776 KB Output is correct
62 Correct 156 ms 7948 KB Output is correct
63 Correct 155 ms 8168 KB Output is correct
64 Execution timed out 1160 ms 7848 KB Time limit exceeded
65 Halted 0 ms 0 KB -