답안 #946775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946775 2024-03-15T04:36:30 Z berr Cubeword (CEOI19_cubeword) C++17
100 / 100
629 ms 25484 KB
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;
#define int long long

map<char, int> mp;
int c[11][62][62][62];
int aa[11][63][63];

const int mod = 998244353;

int mul(int x, int y){
	if((x*y)>mod) return x*y%mod;
	return x*y;
}

void sum(int &a){
	if(a>=mod) a-=mod;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int cnt=0;

	for(int i='a'; i<='z'; i++) mp[i]=cnt++;
	for(int i='A'; i<='Z'; i++)	mp[i]=cnt++;
	for(int i='0'; i<='9'; i++)	mp[i]=cnt++;
	
	int n; cin>>n;
	vector<string> s(n), x;
		
	for(auto &i: s){
		cin >> i;
		string x = i;
		reverse(x.begin(), x.end());
		if(x<i) i=x;
	}

	sort(s.begin(), s.end());
	for(int i=0; i<n; i++){
		if(i==0||s[i]!=s[i-1]) x.push_back(s[i]);
	}

	s=x;
	n = s.size();	

	for(int i=0; i<n; i++){
		string x=s[i];
		reverse(x.begin(), x.end());
		if(x==s[i]) aa[x.size()][mp[x[0]]][mp[x.back()]]++;
		else aa[x.size()][mp[x[0]]][mp[x.back()]]++, aa[x.size()][mp[x.back()]][mp[x[0]]]++;
	}
	for(int i=3; i<=10; i++){
		for(int j=0; j<62; j++){
			for(int a=0; a<62; a++){
				for(int b=0; b<62; b++){
					for(int cc=0; cc<62; cc++){
						c[i][a][b][cc] += mul(aa[i][j][a], mul(aa[i][j][b], aa[i][j][cc]));
						sum(c[i][a][b][cc]);
					}
				}
			}
		}
	}

	int ans=0;
	for(int i=3; i<=10; i++){
		for(int j=0; j<62; j++){
			for(int a=0; a<62; a++){
				for(int b=0; b<62; b++){
					for(int cc=0; cc<62; cc++){
						ans += mul(mul(c[i][j][a][b], c[i][j][a][cc]), mul(c[i][a][b][cc], c[i][j][b][cc]));
						sum(ans);
					}
				}
			}
		}

	}

	cout<<ans;

}   
# 결과 실행 시간 메모리 Grader output
1 Correct 473 ms 23608 KB Output is correct
2 Correct 484 ms 23800 KB Output is correct
3 Correct 471 ms 23432 KB Output is correct
4 Correct 515 ms 23416 KB Output is correct
5 Correct 506 ms 23448 KB Output is correct
6 Correct 519 ms 23488 KB Output is correct
7 Correct 480 ms 23728 KB Output is correct
8 Correct 473 ms 23996 KB Output is correct
9 Correct 465 ms 24440 KB Output is correct
10 Correct 496 ms 24252 KB Output is correct
11 Correct 465 ms 24448 KB Output is correct
12 Correct 502 ms 23492 KB Output is correct
13 Correct 481 ms 24432 KB Output is correct
14 Correct 466 ms 23432 KB Output is correct
15 Correct 475 ms 24168 KB Output is correct
16 Correct 493 ms 23520 KB Output is correct
17 Correct 513 ms 24244 KB Output is correct
18 Correct 519 ms 23740 KB Output is correct
19 Correct 487 ms 23940 KB Output is correct
20 Correct 491 ms 23416 KB Output is correct
21 Correct 487 ms 23484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 473 ms 23608 KB Output is correct
2 Correct 484 ms 23800 KB Output is correct
3 Correct 471 ms 23432 KB Output is correct
4 Correct 515 ms 23416 KB Output is correct
5 Correct 506 ms 23448 KB Output is correct
6 Correct 519 ms 23488 KB Output is correct
7 Correct 480 ms 23728 KB Output is correct
8 Correct 473 ms 23996 KB Output is correct
9 Correct 465 ms 24440 KB Output is correct
10 Correct 496 ms 24252 KB Output is correct
11 Correct 465 ms 24448 KB Output is correct
12 Correct 502 ms 23492 KB Output is correct
13 Correct 481 ms 24432 KB Output is correct
14 Correct 466 ms 23432 KB Output is correct
15 Correct 475 ms 24168 KB Output is correct
16 Correct 493 ms 23520 KB Output is correct
17 Correct 513 ms 24244 KB Output is correct
18 Correct 519 ms 23740 KB Output is correct
19 Correct 487 ms 23940 KB Output is correct
20 Correct 491 ms 23416 KB Output is correct
21 Correct 487 ms 23484 KB Output is correct
22 Correct 468 ms 23744 KB Output is correct
23 Correct 479 ms 23868 KB Output is correct
24 Correct 477 ms 23744 KB Output is correct
25 Correct 471 ms 23744 KB Output is correct
26 Correct 474 ms 23524 KB Output is correct
27 Correct 487 ms 23668 KB Output is correct
28 Correct 485 ms 23740 KB Output is correct
29 Correct 499 ms 23560 KB Output is correct
30 Correct 477 ms 23744 KB Output is correct
31 Correct 470 ms 23740 KB Output is correct
32 Correct 480 ms 23740 KB Output is correct
33 Correct 479 ms 23996 KB Output is correct
34 Correct 470 ms 23672 KB Output is correct
35 Correct 527 ms 23708 KB Output is correct
36 Correct 476 ms 24256 KB Output is correct
37 Correct 497 ms 23744 KB Output is correct
38 Correct 475 ms 23996 KB Output is correct
39 Correct 477 ms 23528 KB Output is correct
40 Correct 492 ms 24408 KB Output is correct
41 Correct 488 ms 24764 KB Output is correct
42 Correct 468 ms 24768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 473 ms 23608 KB Output is correct
2 Correct 484 ms 23800 KB Output is correct
3 Correct 471 ms 23432 KB Output is correct
4 Correct 515 ms 23416 KB Output is correct
5 Correct 506 ms 23448 KB Output is correct
6 Correct 519 ms 23488 KB Output is correct
7 Correct 480 ms 23728 KB Output is correct
8 Correct 473 ms 23996 KB Output is correct
9 Correct 465 ms 24440 KB Output is correct
10 Correct 496 ms 24252 KB Output is correct
11 Correct 465 ms 24448 KB Output is correct
12 Correct 502 ms 23492 KB Output is correct
13 Correct 481 ms 24432 KB Output is correct
14 Correct 466 ms 23432 KB Output is correct
15 Correct 475 ms 24168 KB Output is correct
16 Correct 493 ms 23520 KB Output is correct
17 Correct 513 ms 24244 KB Output is correct
18 Correct 519 ms 23740 KB Output is correct
19 Correct 487 ms 23940 KB Output is correct
20 Correct 491 ms 23416 KB Output is correct
21 Correct 487 ms 23484 KB Output is correct
22 Correct 468 ms 23744 KB Output is correct
23 Correct 479 ms 23868 KB Output is correct
24 Correct 477 ms 23744 KB Output is correct
25 Correct 471 ms 23744 KB Output is correct
26 Correct 474 ms 23524 KB Output is correct
27 Correct 487 ms 23668 KB Output is correct
28 Correct 485 ms 23740 KB Output is correct
29 Correct 499 ms 23560 KB Output is correct
30 Correct 477 ms 23744 KB Output is correct
31 Correct 470 ms 23740 KB Output is correct
32 Correct 480 ms 23740 KB Output is correct
33 Correct 479 ms 23996 KB Output is correct
34 Correct 470 ms 23672 KB Output is correct
35 Correct 527 ms 23708 KB Output is correct
36 Correct 476 ms 24256 KB Output is correct
37 Correct 497 ms 23744 KB Output is correct
38 Correct 475 ms 23996 KB Output is correct
39 Correct 477 ms 23528 KB Output is correct
40 Correct 492 ms 24408 KB Output is correct
41 Correct 488 ms 24764 KB Output is correct
42 Correct 468 ms 24768 KB Output is correct
43 Correct 513 ms 25016 KB Output is correct
44 Correct 511 ms 24284 KB Output is correct
45 Correct 490 ms 25020 KB Output is correct
46 Correct 503 ms 25484 KB Output is correct
47 Correct 489 ms 25012 KB Output is correct
48 Correct 491 ms 24308 KB Output is correct
49 Correct 496 ms 24588 KB Output is correct
50 Correct 492 ms 24132 KB Output is correct
51 Correct 507 ms 24512 KB Output is correct
52 Correct 506 ms 25280 KB Output is correct
53 Correct 522 ms 24120 KB Output is correct
54 Correct 490 ms 24788 KB Output is correct
55 Correct 487 ms 25316 KB Output is correct
56 Correct 511 ms 24304 KB Output is correct
57 Correct 496 ms 24172 KB Output is correct
58 Correct 504 ms 24320 KB Output is correct
59 Correct 494 ms 24248 KB Output is correct
60 Correct 510 ms 24952 KB Output is correct
61 Correct 529 ms 24448 KB Output is correct
62 Correct 493 ms 24256 KB Output is correct
63 Correct 500 ms 24172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 473 ms 23608 KB Output is correct
2 Correct 484 ms 23800 KB Output is correct
3 Correct 471 ms 23432 KB Output is correct
4 Correct 515 ms 23416 KB Output is correct
5 Correct 506 ms 23448 KB Output is correct
6 Correct 519 ms 23488 KB Output is correct
7 Correct 480 ms 23728 KB Output is correct
8 Correct 473 ms 23996 KB Output is correct
9 Correct 465 ms 24440 KB Output is correct
10 Correct 496 ms 24252 KB Output is correct
11 Correct 465 ms 24448 KB Output is correct
12 Correct 502 ms 23492 KB Output is correct
13 Correct 481 ms 24432 KB Output is correct
14 Correct 466 ms 23432 KB Output is correct
15 Correct 475 ms 24168 KB Output is correct
16 Correct 493 ms 23520 KB Output is correct
17 Correct 513 ms 24244 KB Output is correct
18 Correct 519 ms 23740 KB Output is correct
19 Correct 487 ms 23940 KB Output is correct
20 Correct 491 ms 23416 KB Output is correct
21 Correct 487 ms 23484 KB Output is correct
22 Correct 468 ms 23744 KB Output is correct
23 Correct 479 ms 23868 KB Output is correct
24 Correct 477 ms 23744 KB Output is correct
25 Correct 471 ms 23744 KB Output is correct
26 Correct 474 ms 23524 KB Output is correct
27 Correct 487 ms 23668 KB Output is correct
28 Correct 485 ms 23740 KB Output is correct
29 Correct 499 ms 23560 KB Output is correct
30 Correct 477 ms 23744 KB Output is correct
31 Correct 470 ms 23740 KB Output is correct
32 Correct 480 ms 23740 KB Output is correct
33 Correct 479 ms 23996 KB Output is correct
34 Correct 470 ms 23672 KB Output is correct
35 Correct 527 ms 23708 KB Output is correct
36 Correct 476 ms 24256 KB Output is correct
37 Correct 497 ms 23744 KB Output is correct
38 Correct 475 ms 23996 KB Output is correct
39 Correct 477 ms 23528 KB Output is correct
40 Correct 492 ms 24408 KB Output is correct
41 Correct 488 ms 24764 KB Output is correct
42 Correct 468 ms 24768 KB Output is correct
43 Correct 513 ms 25016 KB Output is correct
44 Correct 511 ms 24284 KB Output is correct
45 Correct 490 ms 25020 KB Output is correct
46 Correct 503 ms 25484 KB Output is correct
47 Correct 489 ms 25012 KB Output is correct
48 Correct 491 ms 24308 KB Output is correct
49 Correct 496 ms 24588 KB Output is correct
50 Correct 492 ms 24132 KB Output is correct
51 Correct 507 ms 24512 KB Output is correct
52 Correct 506 ms 25280 KB Output is correct
53 Correct 522 ms 24120 KB Output is correct
54 Correct 490 ms 24788 KB Output is correct
55 Correct 487 ms 25316 KB Output is correct
56 Correct 511 ms 24304 KB Output is correct
57 Correct 496 ms 24172 KB Output is correct
58 Correct 504 ms 24320 KB Output is correct
59 Correct 494 ms 24248 KB Output is correct
60 Correct 510 ms 24952 KB Output is correct
61 Correct 529 ms 24448 KB Output is correct
62 Correct 493 ms 24256 KB Output is correct
63 Correct 500 ms 24172 KB Output is correct
64 Correct 615 ms 25280 KB Output is correct
65 Correct 584 ms 25020 KB Output is correct
66 Correct 583 ms 24380 KB Output is correct
67 Correct 629 ms 24176 KB Output is correct
68 Correct 579 ms 24196 KB Output is correct
69 Correct 617 ms 24768 KB Output is correct
70 Correct 582 ms 24256 KB Output is correct
71 Correct 605 ms 24512 KB Output is correct
72 Correct 596 ms 24768 KB Output is correct
73 Correct 592 ms 24508 KB Output is correct
74 Correct 618 ms 24276 KB Output is correct
75 Correct 617 ms 25320 KB Output is correct
76 Correct 599 ms 24348 KB Output is correct
77 Correct 613 ms 24200 KB Output is correct
78 Correct 586 ms 24256 KB Output is correct
79 Correct 596 ms 24592 KB Output is correct
80 Correct 621 ms 24180 KB Output is correct
81 Correct 596 ms 24256 KB Output is correct
82 Correct 610 ms 24436 KB Output is correct
83 Correct 623 ms 24260 KB Output is correct
84 Correct 610 ms 25224 KB Output is correct