답안 #604783

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
604783 2022-07-25T09:46:27 Z 1bin Cubeword (CEOI19_cubeword) C++14
100 / 100
428 ms 50568 KB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1e5 + 5;
const ll mod = 998244353;
ll n, ans, t[11][64][64], cnt[64][64][64], a, b, m[64][64][64][64];
string s;
set<string> st;

int chg(char c){
    if(c >= '0' && c <= '9') return c - '0';
    else if(c >= 'a' && c <= 'z') return c - 'a' + 10;
    else return c - 'A' + 36;
}

void solve(int l){
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < 64; i++)
        for(int j = i; j < 64; j++)
            for(int k = j; k < 64; k++)
                for(int x = 0; x < 64; x++)
                    cnt[i][j][k] += t[l][i][x] * t[l][j][x] * t[l][k][x], cnt[i][j][k] %= mod;
    
    for(int i = 0; i < 64; i++)
        for(int j = i; j < 64; j++)
            for(int k = j; k < 64; k++)
                for(int l = k; l < 64; l++)
                    ans += 24 / m[i][j][k][l] * cnt[i][j][k] % mod * cnt[i][j][l] % mod * cnt[i][k][l] % mod * cnt[j][k][l] % mod, ans %= mod;
    return;
}

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    for(int i = 0; i < 64; i++)
        for(int j = i; j < 64; j++)
            for(int k = j; k < 64; k++)
                for(int l = k; l < 64; l++){
                    if(i == l) m[i][j][k][l] = 24;
                    else if(i == k || j == l) m[i][j][k][l] = 6;
                    else if(i == j && k == l) m[i][j][k][l] = 4;
                    else if(i == j || j == k || k == l) m[i][j][k][l] = 2;
                    else m[i][j][k][l] = 1;
                }
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s; st.emplace(s);
        reverse(all(s)); st.emplace(s);
    }
    for(auto & s : st){
        a = chg(s[0]); b = chg(s[s.size() - 1]);
        t[s.size()][a][b]++;
    }
    
    for(int i = 3; i <= 10; i++) solve(i);
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 322 ms 49400 KB Output is correct
2 Correct 319 ms 49380 KB Output is correct
3 Correct 331 ms 49392 KB Output is correct
4 Correct 341 ms 49276 KB Output is correct
5 Correct 323 ms 49272 KB Output is correct
6 Correct 394 ms 49356 KB Output is correct
7 Correct 331 ms 49408 KB Output is correct
8 Correct 319 ms 49272 KB Output is correct
9 Correct 331 ms 49380 KB Output is correct
10 Correct 325 ms 49368 KB Output is correct
11 Correct 322 ms 49388 KB Output is correct
12 Correct 326 ms 49284 KB Output is correct
13 Correct 316 ms 49400 KB Output is correct
14 Correct 309 ms 49400 KB Output is correct
15 Correct 343 ms 49392 KB Output is correct
16 Correct 305 ms 49280 KB Output is correct
17 Correct 313 ms 49392 KB Output is correct
18 Correct 326 ms 49496 KB Output is correct
19 Correct 322 ms 49376 KB Output is correct
20 Correct 321 ms 49392 KB Output is correct
21 Correct 345 ms 49356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 322 ms 49400 KB Output is correct
2 Correct 319 ms 49380 KB Output is correct
3 Correct 331 ms 49392 KB Output is correct
4 Correct 341 ms 49276 KB Output is correct
5 Correct 323 ms 49272 KB Output is correct
6 Correct 394 ms 49356 KB Output is correct
7 Correct 331 ms 49408 KB Output is correct
8 Correct 319 ms 49272 KB Output is correct
9 Correct 331 ms 49380 KB Output is correct
10 Correct 325 ms 49368 KB Output is correct
11 Correct 322 ms 49388 KB Output is correct
12 Correct 326 ms 49284 KB Output is correct
13 Correct 316 ms 49400 KB Output is correct
14 Correct 309 ms 49400 KB Output is correct
15 Correct 343 ms 49392 KB Output is correct
16 Correct 305 ms 49280 KB Output is correct
17 Correct 313 ms 49392 KB Output is correct
18 Correct 326 ms 49496 KB Output is correct
19 Correct 322 ms 49376 KB Output is correct
20 Correct 321 ms 49392 KB Output is correct
21 Correct 345 ms 49356 KB Output is correct
22 Correct 327 ms 49996 KB Output is correct
23 Correct 375 ms 49988 KB Output is correct
24 Correct 367 ms 49996 KB Output is correct
25 Correct 317 ms 49864 KB Output is correct
26 Correct 352 ms 49936 KB Output is correct
27 Correct 363 ms 49956 KB Output is correct
28 Correct 354 ms 49916 KB Output is correct
29 Correct 387 ms 50124 KB Output is correct
30 Correct 341 ms 49992 KB Output is correct
31 Correct 358 ms 49996 KB Output is correct
32 Correct 349 ms 49864 KB Output is correct
33 Correct 368 ms 49988 KB Output is correct
34 Correct 377 ms 49988 KB Output is correct
35 Correct 372 ms 50108 KB Output is correct
36 Correct 341 ms 49940 KB Output is correct
37 Correct 337 ms 49996 KB Output is correct
38 Correct 352 ms 49928 KB Output is correct
39 Correct 341 ms 49868 KB Output is correct
40 Correct 359 ms 49988 KB Output is correct
41 Correct 331 ms 49996 KB Output is correct
42 Correct 329 ms 49996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 322 ms 49400 KB Output is correct
2 Correct 319 ms 49380 KB Output is correct
3 Correct 331 ms 49392 KB Output is correct
4 Correct 341 ms 49276 KB Output is correct
5 Correct 323 ms 49272 KB Output is correct
6 Correct 394 ms 49356 KB Output is correct
7 Correct 331 ms 49408 KB Output is correct
8 Correct 319 ms 49272 KB Output is correct
9 Correct 331 ms 49380 KB Output is correct
10 Correct 325 ms 49368 KB Output is correct
11 Correct 322 ms 49388 KB Output is correct
12 Correct 326 ms 49284 KB Output is correct
13 Correct 316 ms 49400 KB Output is correct
14 Correct 309 ms 49400 KB Output is correct
15 Correct 343 ms 49392 KB Output is correct
16 Correct 305 ms 49280 KB Output is correct
17 Correct 313 ms 49392 KB Output is correct
18 Correct 326 ms 49496 KB Output is correct
19 Correct 322 ms 49376 KB Output is correct
20 Correct 321 ms 49392 KB Output is correct
21 Correct 345 ms 49356 KB Output is correct
22 Correct 327 ms 49996 KB Output is correct
23 Correct 375 ms 49988 KB Output is correct
24 Correct 367 ms 49996 KB Output is correct
25 Correct 317 ms 49864 KB Output is correct
26 Correct 352 ms 49936 KB Output is correct
27 Correct 363 ms 49956 KB Output is correct
28 Correct 354 ms 49916 KB Output is correct
29 Correct 387 ms 50124 KB Output is correct
30 Correct 341 ms 49992 KB Output is correct
31 Correct 358 ms 49996 KB Output is correct
32 Correct 349 ms 49864 KB Output is correct
33 Correct 368 ms 49988 KB Output is correct
34 Correct 377 ms 49988 KB Output is correct
35 Correct 372 ms 50108 KB Output is correct
36 Correct 341 ms 49940 KB Output is correct
37 Correct 337 ms 49996 KB Output is correct
38 Correct 352 ms 49928 KB Output is correct
39 Correct 341 ms 49868 KB Output is correct
40 Correct 359 ms 49988 KB Output is correct
41 Correct 331 ms 49996 KB Output is correct
42 Correct 329 ms 49996 KB Output is correct
43 Correct 368 ms 50276 KB Output is correct
44 Correct 376 ms 50280 KB Output is correct
45 Correct 380 ms 50264 KB Output is correct
46 Correct 382 ms 50260 KB Output is correct
47 Correct 372 ms 50216 KB Output is correct
48 Correct 372 ms 50268 KB Output is correct
49 Correct 349 ms 50268 KB Output is correct
50 Correct 408 ms 50276 KB Output is correct
51 Correct 366 ms 50264 KB Output is correct
52 Correct 359 ms 50256 KB Output is correct
53 Correct 373 ms 50176 KB Output is correct
54 Correct 378 ms 50152 KB Output is correct
55 Correct 358 ms 50268 KB Output is correct
56 Correct 374 ms 50268 KB Output is correct
57 Correct 353 ms 50256 KB Output is correct
58 Correct 358 ms 50268 KB Output is correct
59 Correct 357 ms 50264 KB Output is correct
60 Correct 370 ms 50260 KB Output is correct
61 Correct 356 ms 50260 KB Output is correct
62 Correct 356 ms 50260 KB Output is correct
63 Correct 375 ms 50256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 322 ms 49400 KB Output is correct
2 Correct 319 ms 49380 KB Output is correct
3 Correct 331 ms 49392 KB Output is correct
4 Correct 341 ms 49276 KB Output is correct
5 Correct 323 ms 49272 KB Output is correct
6 Correct 394 ms 49356 KB Output is correct
7 Correct 331 ms 49408 KB Output is correct
8 Correct 319 ms 49272 KB Output is correct
9 Correct 331 ms 49380 KB Output is correct
10 Correct 325 ms 49368 KB Output is correct
11 Correct 322 ms 49388 KB Output is correct
12 Correct 326 ms 49284 KB Output is correct
13 Correct 316 ms 49400 KB Output is correct
14 Correct 309 ms 49400 KB Output is correct
15 Correct 343 ms 49392 KB Output is correct
16 Correct 305 ms 49280 KB Output is correct
17 Correct 313 ms 49392 KB Output is correct
18 Correct 326 ms 49496 KB Output is correct
19 Correct 322 ms 49376 KB Output is correct
20 Correct 321 ms 49392 KB Output is correct
21 Correct 345 ms 49356 KB Output is correct
22 Correct 327 ms 49996 KB Output is correct
23 Correct 375 ms 49988 KB Output is correct
24 Correct 367 ms 49996 KB Output is correct
25 Correct 317 ms 49864 KB Output is correct
26 Correct 352 ms 49936 KB Output is correct
27 Correct 363 ms 49956 KB Output is correct
28 Correct 354 ms 49916 KB Output is correct
29 Correct 387 ms 50124 KB Output is correct
30 Correct 341 ms 49992 KB Output is correct
31 Correct 358 ms 49996 KB Output is correct
32 Correct 349 ms 49864 KB Output is correct
33 Correct 368 ms 49988 KB Output is correct
34 Correct 377 ms 49988 KB Output is correct
35 Correct 372 ms 50108 KB Output is correct
36 Correct 341 ms 49940 KB Output is correct
37 Correct 337 ms 49996 KB Output is correct
38 Correct 352 ms 49928 KB Output is correct
39 Correct 341 ms 49868 KB Output is correct
40 Correct 359 ms 49988 KB Output is correct
41 Correct 331 ms 49996 KB Output is correct
42 Correct 329 ms 49996 KB Output is correct
43 Correct 368 ms 50276 KB Output is correct
44 Correct 376 ms 50280 KB Output is correct
45 Correct 380 ms 50264 KB Output is correct
46 Correct 382 ms 50260 KB Output is correct
47 Correct 372 ms 50216 KB Output is correct
48 Correct 372 ms 50268 KB Output is correct
49 Correct 349 ms 50268 KB Output is correct
50 Correct 408 ms 50276 KB Output is correct
51 Correct 366 ms 50264 KB Output is correct
52 Correct 359 ms 50256 KB Output is correct
53 Correct 373 ms 50176 KB Output is correct
54 Correct 378 ms 50152 KB Output is correct
55 Correct 358 ms 50268 KB Output is correct
56 Correct 374 ms 50268 KB Output is correct
57 Correct 353 ms 50256 KB Output is correct
58 Correct 358 ms 50268 KB Output is correct
59 Correct 357 ms 50264 KB Output is correct
60 Correct 370 ms 50260 KB Output is correct
61 Correct 356 ms 50260 KB Output is correct
62 Correct 356 ms 50260 KB Output is correct
63 Correct 375 ms 50256 KB Output is correct
64 Correct 399 ms 50568 KB Output is correct
65 Correct 428 ms 50568 KB Output is correct
66 Correct 390 ms 50560 KB Output is correct
67 Correct 343 ms 50556 KB Output is correct
68 Correct 381 ms 50444 KB Output is correct
69 Correct 395 ms 50500 KB Output is correct
70 Correct 370 ms 50440 KB Output is correct
71 Correct 371 ms 50556 KB Output is correct
72 Correct 372 ms 50524 KB Output is correct
73 Correct 357 ms 50560 KB Output is correct
74 Correct 401 ms 50564 KB Output is correct
75 Correct 398 ms 50556 KB Output is correct
76 Correct 376 ms 50508 KB Output is correct
77 Correct 405 ms 50564 KB Output is correct
78 Correct 365 ms 50560 KB Output is correct
79 Correct 371 ms 50560 KB Output is correct
80 Correct 350 ms 50560 KB Output is correct
81 Correct 371 ms 50468 KB Output is correct
82 Correct 369 ms 50508 KB Output is correct
83 Correct 402 ms 50500 KB Output is correct
84 Correct 361 ms 50556 KB Output is correct