답안 #786441

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
786441 2023-07-18T07:48:25 Z blue Cubeword (CEOI19_cubeword) C++17
50 / 100
239 ms 35692 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
#define sz(x) int(x.size())

const ll mod = 998'244'353LL;

const int Z = 32;

int ad(ll a, ll b)
{
	return (a + b) % mod;
}

void selfadd(int& a, ll b)
{
	a = ad(a, b);
}

int mul(ll a, ll b)
{
	return (a * b) % mod;
}

int getnum(char c)
{
	if('a' <= c && c <= 'z')
		return c - 'a';
	else if('A' <= c && c <= 'Z')
		return 26 + c - 'A';
	else if('0' <= c && c <= '9')
		return 26 + 26 + c - '0';
	else
		assert(0);

	// if('a' <= c && c <= 'z')
	// 	return c - 'a';
	// else
	// 	return 16 + c - 'A';
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	set<string> words;

	for(int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;

		words.insert(s);

		reverse(s.begin(), s.end());

		words.insert(s);
	}

	vector<pii> wl[11];

	for(string w : words)
	{
		wl[sz(w)].push_back({getnum(w[0]), getnum(w.back())});
	}


// cerr << "done\n";

	int res = 0;

	for(int l = 3; l <= 10; l++)
	{
		// cerr << "l = " << l << '\n';
		vvi ct(Z, vi(Z, 0));

		for(pii z : wl[l])
		{
			ct[z.first][z.second]++;
		}

		vvvi ct3(Z, vvi(Z, vi(Z, 0)));

		for(int a = 0; a < Z; a++)
		{
			for(int b = 0; b < Z; b++)
			{
				for(int c = 0; c < Z; c++)
				{
					for(int x = 0; x < Z; x++)
					{
						selfadd(ct3[a][b][c], mul(ct[x][a], mul(ct[x][b], ct[x][c])));
					}
				}
			}
		}

		for(int a = 0; a < Z; a++)
		{
			for(int b = 0; b < Z; b++)
			{
				for(int c = 0; c < Z; c++)
				{
					for(int d = 0; d < Z; d++)
					{
						selfadd(res, mul(ct3[a][b][c], mul(ct3[b][c][d], mul(ct3[c][d][a], ct3[d][a][b]))));
					}
				}
			}
		}
	}

	cout << res << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 16468 KB Output is correct
2 Correct 195 ms 16452 KB Output is correct
3 Correct 209 ms 16600 KB Output is correct
4 Correct 226 ms 16592 KB Output is correct
5 Correct 207 ms 16776 KB Output is correct
6 Correct 221 ms 16880 KB Output is correct
7 Correct 198 ms 16480 KB Output is correct
8 Correct 205 ms 16704 KB Output is correct
9 Correct 223 ms 16560 KB Output is correct
10 Correct 188 ms 16560 KB Output is correct
11 Correct 198 ms 16564 KB Output is correct
12 Correct 227 ms 16516 KB Output is correct
13 Correct 216 ms 16532 KB Output is correct
14 Correct 202 ms 16440 KB Output is correct
15 Correct 199 ms 16404 KB Output is correct
16 Correct 216 ms 16788 KB Output is correct
17 Correct 198 ms 16736 KB Output is correct
18 Correct 196 ms 16680 KB Output is correct
19 Correct 203 ms 16744 KB Output is correct
20 Correct 200 ms 16724 KB Output is correct
21 Correct 201 ms 16448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 16468 KB Output is correct
2 Correct 195 ms 16452 KB Output is correct
3 Correct 209 ms 16600 KB Output is correct
4 Correct 226 ms 16592 KB Output is correct
5 Correct 207 ms 16776 KB Output is correct
6 Correct 221 ms 16880 KB Output is correct
7 Correct 198 ms 16480 KB Output is correct
8 Correct 205 ms 16704 KB Output is correct
9 Correct 223 ms 16560 KB Output is correct
10 Correct 188 ms 16560 KB Output is correct
11 Correct 198 ms 16564 KB Output is correct
12 Correct 227 ms 16516 KB Output is correct
13 Correct 216 ms 16532 KB Output is correct
14 Correct 202 ms 16440 KB Output is correct
15 Correct 199 ms 16404 KB Output is correct
16 Correct 216 ms 16788 KB Output is correct
17 Correct 198 ms 16736 KB Output is correct
18 Correct 196 ms 16680 KB Output is correct
19 Correct 203 ms 16744 KB Output is correct
20 Correct 200 ms 16724 KB Output is correct
21 Correct 201 ms 16448 KB Output is correct
22 Correct 239 ms 17196 KB Output is correct
23 Correct 209 ms 17228 KB Output is correct
24 Correct 199 ms 17260 KB Output is correct
25 Correct 204 ms 17208 KB Output is correct
26 Correct 200 ms 17160 KB Output is correct
27 Correct 218 ms 17320 KB Output is correct
28 Correct 201 ms 17396 KB Output is correct
29 Correct 209 ms 17264 KB Output is correct
30 Correct 196 ms 17208 KB Output is correct
31 Correct 196 ms 17256 KB Output is correct
32 Correct 208 ms 17408 KB Output is correct
33 Correct 201 ms 17160 KB Output is correct
34 Correct 216 ms 17392 KB Output is correct
35 Correct 231 ms 17260 KB Output is correct
36 Correct 194 ms 17512 KB Output is correct
37 Correct 221 ms 17224 KB Output is correct
38 Correct 205 ms 17148 KB Output is correct
39 Correct 201 ms 17356 KB Output is correct
40 Correct 202 ms 17168 KB Output is correct
41 Correct 206 ms 17252 KB Output is correct
42 Correct 207 ms 17136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 16468 KB Output is correct
2 Correct 195 ms 16452 KB Output is correct
3 Correct 209 ms 16600 KB Output is correct
4 Correct 226 ms 16592 KB Output is correct
5 Correct 207 ms 16776 KB Output is correct
6 Correct 221 ms 16880 KB Output is correct
7 Correct 198 ms 16480 KB Output is correct
8 Correct 205 ms 16704 KB Output is correct
9 Correct 223 ms 16560 KB Output is correct
10 Correct 188 ms 16560 KB Output is correct
11 Correct 198 ms 16564 KB Output is correct
12 Correct 227 ms 16516 KB Output is correct
13 Correct 216 ms 16532 KB Output is correct
14 Correct 202 ms 16440 KB Output is correct
15 Correct 199 ms 16404 KB Output is correct
16 Correct 216 ms 16788 KB Output is correct
17 Correct 198 ms 16736 KB Output is correct
18 Correct 196 ms 16680 KB Output is correct
19 Correct 203 ms 16744 KB Output is correct
20 Correct 200 ms 16724 KB Output is correct
21 Correct 201 ms 16448 KB Output is correct
22 Correct 239 ms 17196 KB Output is correct
23 Correct 209 ms 17228 KB Output is correct
24 Correct 199 ms 17260 KB Output is correct
25 Correct 204 ms 17208 KB Output is correct
26 Correct 200 ms 17160 KB Output is correct
27 Correct 218 ms 17320 KB Output is correct
28 Correct 201 ms 17396 KB Output is correct
29 Correct 209 ms 17264 KB Output is correct
30 Correct 196 ms 17208 KB Output is correct
31 Correct 196 ms 17256 KB Output is correct
32 Correct 208 ms 17408 KB Output is correct
33 Correct 201 ms 17160 KB Output is correct
34 Correct 216 ms 17392 KB Output is correct
35 Correct 231 ms 17260 KB Output is correct
36 Correct 194 ms 17512 KB Output is correct
37 Correct 221 ms 17224 KB Output is correct
38 Correct 205 ms 17148 KB Output is correct
39 Correct 201 ms 17356 KB Output is correct
40 Correct 202 ms 17168 KB Output is correct
41 Correct 206 ms 17252 KB Output is correct
42 Correct 207 ms 17136 KB Output is correct
43 Runtime error 117 ms 35692 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 16468 KB Output is correct
2 Correct 195 ms 16452 KB Output is correct
3 Correct 209 ms 16600 KB Output is correct
4 Correct 226 ms 16592 KB Output is correct
5 Correct 207 ms 16776 KB Output is correct
6 Correct 221 ms 16880 KB Output is correct
7 Correct 198 ms 16480 KB Output is correct
8 Correct 205 ms 16704 KB Output is correct
9 Correct 223 ms 16560 KB Output is correct
10 Correct 188 ms 16560 KB Output is correct
11 Correct 198 ms 16564 KB Output is correct
12 Correct 227 ms 16516 KB Output is correct
13 Correct 216 ms 16532 KB Output is correct
14 Correct 202 ms 16440 KB Output is correct
15 Correct 199 ms 16404 KB Output is correct
16 Correct 216 ms 16788 KB Output is correct
17 Correct 198 ms 16736 KB Output is correct
18 Correct 196 ms 16680 KB Output is correct
19 Correct 203 ms 16744 KB Output is correct
20 Correct 200 ms 16724 KB Output is correct
21 Correct 201 ms 16448 KB Output is correct
22 Correct 239 ms 17196 KB Output is correct
23 Correct 209 ms 17228 KB Output is correct
24 Correct 199 ms 17260 KB Output is correct
25 Correct 204 ms 17208 KB Output is correct
26 Correct 200 ms 17160 KB Output is correct
27 Correct 218 ms 17320 KB Output is correct
28 Correct 201 ms 17396 KB Output is correct
29 Correct 209 ms 17264 KB Output is correct
30 Correct 196 ms 17208 KB Output is correct
31 Correct 196 ms 17256 KB Output is correct
32 Correct 208 ms 17408 KB Output is correct
33 Correct 201 ms 17160 KB Output is correct
34 Correct 216 ms 17392 KB Output is correct
35 Correct 231 ms 17260 KB Output is correct
36 Correct 194 ms 17512 KB Output is correct
37 Correct 221 ms 17224 KB Output is correct
38 Correct 205 ms 17148 KB Output is correct
39 Correct 201 ms 17356 KB Output is correct
40 Correct 202 ms 17168 KB Output is correct
41 Correct 206 ms 17252 KB Output is correct
42 Correct 207 ms 17136 KB Output is correct
43 Runtime error 117 ms 35692 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -