답안 #1025515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025515 2024-07-17T05:54:20 Z 정희우(#10943) Cubeword (CEOI19_cubeword) C++17
100 / 100
240 ms 24512 KB
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
using lint = long long;
using intp = pair<int,int>;
using vint = vector<int>;

const int MAX_N=100010;
const int AN=62;
const int MAX_L=8;
const lint MOD=998244353;

int n;
vector<string> w;
lint cnt[MAX_L][AN][AN];
lint cnt2[MAX_L][AN][AN][AN];

int lti(char c)
{
    if('A'<=c && c<='Z')
        return c-'A';
    if('a'<=c && c<='z')
        return c-'a'+26;
    return c-'0'+52;
}

string revs(string s)
{
    int l=s.size();
    for(int i=0;i*2<l;i++)
        swap(s[i],s[l-1-i]);
    return s;
}

void value(lint &v,const int &l,const int &a1,const int &a2,const int &a3,const int &a4)
{
    int times=24;
    if(a1==a2 && a2==a3 && a3==a4)
        times=1;
    else if(a2==a3 && (a1==a2 || a3==a4))
        times=4;
    else if(a1==a2 && a3==a4)
        times=6;
    else if(a1==a2 || a2==a3 || a3==a4)
        times=12;
    v=(v+(((cnt2[l][a1][a2][a3]*cnt2[l][a1][a2][a4])%MOD)*((cnt2[l][a1][a3][a4]*cnt2[l][a2][a3][a4])%MOD)%MOD)*times)%MOD;
}

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
        w.push_back(s);
        w.push_back(revs(s));
    }
    sort(w.begin(),w.end());
    w.resize(unique(w.begin(),w.end())-w.begin());
    for(auto s : w)
        cnt[s.size()-3][lti(s[0])][lti(s[s.size()-1])]++;
    for(int l=0;l<8;l++)
        for(int a1=0;a1<AN;a1++)
            for(int a2=a1;a2<AN;a2++)
                for(int a3=a2;a3<AN;a3++)
                {
                    lint v=0;
                    for(int t=0;t<AN;t++)
                        v=(v+cnt[l][a1][t]*cnt[l][a2][t]*cnt[l][a3][t])%MOD;
                    cnt2[l][a1][a2][a3]=v;
                }
    lint ans=0;
    for(int l=0;l<8;l++)
        for(int a1=0;a1<AN;a1++)
            for(int a2=a1;a2<AN;a2++)
                for(int a3=a2;a3<AN;a3++)
                    for(int a4=a3;a4<AN;a4++)
                        value(ans,l,a1,a2,a3,a4);
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 186 ms 21684 KB Output is correct
2 Correct 182 ms 22964 KB Output is correct
3 Correct 181 ms 21948 KB Output is correct
4 Correct 186 ms 21688 KB Output is correct
5 Correct 180 ms 21684 KB Output is correct
6 Correct 180 ms 22708 KB Output is correct
7 Correct 186 ms 22964 KB Output is correct
8 Correct 181 ms 23196 KB Output is correct
9 Correct 181 ms 22968 KB Output is correct
10 Correct 180 ms 21556 KB Output is correct
11 Correct 180 ms 22980 KB Output is correct
12 Correct 183 ms 22864 KB Output is correct
13 Correct 181 ms 21940 KB Output is correct
14 Correct 181 ms 22452 KB Output is correct
15 Correct 184 ms 21428 KB Output is correct
16 Correct 180 ms 21944 KB Output is correct
17 Correct 192 ms 22840 KB Output is correct
18 Correct 180 ms 23484 KB Output is correct
19 Correct 184 ms 22964 KB Output is correct
20 Correct 180 ms 21420 KB Output is correct
21 Correct 184 ms 22708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 186 ms 21684 KB Output is correct
2 Correct 182 ms 22964 KB Output is correct
3 Correct 181 ms 21948 KB Output is correct
4 Correct 186 ms 21688 KB Output is correct
5 Correct 180 ms 21684 KB Output is correct
6 Correct 180 ms 22708 KB Output is correct
7 Correct 186 ms 22964 KB Output is correct
8 Correct 181 ms 23196 KB Output is correct
9 Correct 181 ms 22968 KB Output is correct
10 Correct 180 ms 21556 KB Output is correct
11 Correct 180 ms 22980 KB Output is correct
12 Correct 183 ms 22864 KB Output is correct
13 Correct 181 ms 21940 KB Output is correct
14 Correct 181 ms 22452 KB Output is correct
15 Correct 184 ms 21428 KB Output is correct
16 Correct 180 ms 21944 KB Output is correct
17 Correct 192 ms 22840 KB Output is correct
18 Correct 180 ms 23484 KB Output is correct
19 Correct 184 ms 22964 KB Output is correct
20 Correct 180 ms 21420 KB Output is correct
21 Correct 184 ms 22708 KB Output is correct
22 Correct 178 ms 22964 KB Output is correct
23 Correct 179 ms 22540 KB Output is correct
24 Correct 189 ms 23228 KB Output is correct
25 Correct 185 ms 22308 KB Output is correct
26 Correct 181 ms 22768 KB Output is correct
27 Correct 182 ms 23016 KB Output is correct
28 Correct 192 ms 22708 KB Output is correct
29 Correct 189 ms 22452 KB Output is correct
30 Correct 188 ms 21800 KB Output is correct
31 Correct 195 ms 23064 KB Output is correct
32 Correct 183 ms 22460 KB Output is correct
33 Correct 184 ms 23340 KB Output is correct
34 Correct 182 ms 22164 KB Output is correct
35 Correct 187 ms 21732 KB Output is correct
36 Correct 194 ms 22928 KB Output is correct
37 Correct 240 ms 22968 KB Output is correct
38 Correct 190 ms 22140 KB Output is correct
39 Correct 188 ms 22656 KB Output is correct
40 Correct 189 ms 22964 KB Output is correct
41 Correct 184 ms 21692 KB Output is correct
42 Correct 183 ms 22492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 186 ms 21684 KB Output is correct
2 Correct 182 ms 22964 KB Output is correct
3 Correct 181 ms 21948 KB Output is correct
4 Correct 186 ms 21688 KB Output is correct
5 Correct 180 ms 21684 KB Output is correct
6 Correct 180 ms 22708 KB Output is correct
7 Correct 186 ms 22964 KB Output is correct
8 Correct 181 ms 23196 KB Output is correct
9 Correct 181 ms 22968 KB Output is correct
10 Correct 180 ms 21556 KB Output is correct
11 Correct 180 ms 22980 KB Output is correct
12 Correct 183 ms 22864 KB Output is correct
13 Correct 181 ms 21940 KB Output is correct
14 Correct 181 ms 22452 KB Output is correct
15 Correct 184 ms 21428 KB Output is correct
16 Correct 180 ms 21944 KB Output is correct
17 Correct 192 ms 22840 KB Output is correct
18 Correct 180 ms 23484 KB Output is correct
19 Correct 184 ms 22964 KB Output is correct
20 Correct 180 ms 21420 KB Output is correct
21 Correct 184 ms 22708 KB Output is correct
22 Correct 178 ms 22964 KB Output is correct
23 Correct 179 ms 22540 KB Output is correct
24 Correct 189 ms 23228 KB Output is correct
25 Correct 185 ms 22308 KB Output is correct
26 Correct 181 ms 22768 KB Output is correct
27 Correct 182 ms 23016 KB Output is correct
28 Correct 192 ms 22708 KB Output is correct
29 Correct 189 ms 22452 KB Output is correct
30 Correct 188 ms 21800 KB Output is correct
31 Correct 195 ms 23064 KB Output is correct
32 Correct 183 ms 22460 KB Output is correct
33 Correct 184 ms 23340 KB Output is correct
34 Correct 182 ms 22164 KB Output is correct
35 Correct 187 ms 21732 KB Output is correct
36 Correct 194 ms 22928 KB Output is correct
37 Correct 240 ms 22968 KB Output is correct
38 Correct 190 ms 22140 KB Output is correct
39 Correct 188 ms 22656 KB Output is correct
40 Correct 189 ms 22964 KB Output is correct
41 Correct 184 ms 21692 KB Output is correct
42 Correct 183 ms 22492 KB Output is correct
43 Correct 185 ms 22452 KB Output is correct
44 Correct 185 ms 21684 KB Output is correct
45 Correct 188 ms 23116 KB Output is correct
46 Correct 185 ms 22024 KB Output is correct
47 Correct 182 ms 21644 KB Output is correct
48 Correct 185 ms 22096 KB Output is correct
49 Correct 185 ms 21704 KB Output is correct
50 Correct 182 ms 23228 KB Output is correct
51 Correct 187 ms 22968 KB Output is correct
52 Correct 184 ms 21968 KB Output is correct
53 Correct 189 ms 21440 KB Output is correct
54 Correct 190 ms 23224 KB Output is correct
55 Correct 183 ms 22968 KB Output is correct
56 Correct 185 ms 21548 KB Output is correct
57 Correct 183 ms 22452 KB Output is correct
58 Correct 194 ms 23480 KB Output is correct
59 Correct 200 ms 21688 KB Output is correct
60 Correct 183 ms 21904 KB Output is correct
61 Correct 190 ms 22708 KB Output is correct
62 Correct 182 ms 22452 KB Output is correct
63 Correct 187 ms 22196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 186 ms 21684 KB Output is correct
2 Correct 182 ms 22964 KB Output is correct
3 Correct 181 ms 21948 KB Output is correct
4 Correct 186 ms 21688 KB Output is correct
5 Correct 180 ms 21684 KB Output is correct
6 Correct 180 ms 22708 KB Output is correct
7 Correct 186 ms 22964 KB Output is correct
8 Correct 181 ms 23196 KB Output is correct
9 Correct 181 ms 22968 KB Output is correct
10 Correct 180 ms 21556 KB Output is correct
11 Correct 180 ms 22980 KB Output is correct
12 Correct 183 ms 22864 KB Output is correct
13 Correct 181 ms 21940 KB Output is correct
14 Correct 181 ms 22452 KB Output is correct
15 Correct 184 ms 21428 KB Output is correct
16 Correct 180 ms 21944 KB Output is correct
17 Correct 192 ms 22840 KB Output is correct
18 Correct 180 ms 23484 KB Output is correct
19 Correct 184 ms 22964 KB Output is correct
20 Correct 180 ms 21420 KB Output is correct
21 Correct 184 ms 22708 KB Output is correct
22 Correct 178 ms 22964 KB Output is correct
23 Correct 179 ms 22540 KB Output is correct
24 Correct 189 ms 23228 KB Output is correct
25 Correct 185 ms 22308 KB Output is correct
26 Correct 181 ms 22768 KB Output is correct
27 Correct 182 ms 23016 KB Output is correct
28 Correct 192 ms 22708 KB Output is correct
29 Correct 189 ms 22452 KB Output is correct
30 Correct 188 ms 21800 KB Output is correct
31 Correct 195 ms 23064 KB Output is correct
32 Correct 183 ms 22460 KB Output is correct
33 Correct 184 ms 23340 KB Output is correct
34 Correct 182 ms 22164 KB Output is correct
35 Correct 187 ms 21732 KB Output is correct
36 Correct 194 ms 22928 KB Output is correct
37 Correct 240 ms 22968 KB Output is correct
38 Correct 190 ms 22140 KB Output is correct
39 Correct 188 ms 22656 KB Output is correct
40 Correct 189 ms 22964 KB Output is correct
41 Correct 184 ms 21692 KB Output is correct
42 Correct 183 ms 22492 KB Output is correct
43 Correct 185 ms 22452 KB Output is correct
44 Correct 185 ms 21684 KB Output is correct
45 Correct 188 ms 23116 KB Output is correct
46 Correct 185 ms 22024 KB Output is correct
47 Correct 182 ms 21644 KB Output is correct
48 Correct 185 ms 22096 KB Output is correct
49 Correct 185 ms 21704 KB Output is correct
50 Correct 182 ms 23228 KB Output is correct
51 Correct 187 ms 22968 KB Output is correct
52 Correct 184 ms 21968 KB Output is correct
53 Correct 189 ms 21440 KB Output is correct
54 Correct 190 ms 23224 KB Output is correct
55 Correct 183 ms 22968 KB Output is correct
56 Correct 185 ms 21548 KB Output is correct
57 Correct 183 ms 22452 KB Output is correct
58 Correct 194 ms 23480 KB Output is correct
59 Correct 200 ms 21688 KB Output is correct
60 Correct 183 ms 21904 KB Output is correct
61 Correct 190 ms 22708 KB Output is correct
62 Correct 182 ms 22452 KB Output is correct
63 Correct 187 ms 22196 KB Output is correct
64 Correct 182 ms 22968 KB Output is correct
65 Correct 181 ms 23992 KB Output is correct
66 Correct 182 ms 22452 KB Output is correct
67 Correct 191 ms 23392 KB Output is correct
68 Correct 178 ms 23992 KB Output is correct
69 Correct 181 ms 23728 KB Output is correct
70 Correct 189 ms 23220 KB Output is correct
71 Correct 184 ms 24512 KB Output is correct
72 Correct 185 ms 23840 KB Output is correct
73 Correct 184 ms 22712 KB Output is correct
74 Correct 184 ms 22796 KB Output is correct
75 Correct 184 ms 23804 KB Output is correct
76 Correct 204 ms 23992 KB Output is correct
77 Correct 186 ms 24152 KB Output is correct
78 Correct 184 ms 23732 KB Output is correct
79 Correct 192 ms 23816 KB Output is correct
80 Correct 181 ms 22456 KB Output is correct
81 Correct 185 ms 22664 KB Output is correct
82 Correct 186 ms 23988 KB Output is correct
83 Correct 185 ms 22968 KB Output is correct
84 Correct 182 ms 23220 KB Output is correct