# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
786425 |
2023-07-18T07:44:04 Z |
blue |
Cubeword (CEOI19_cubeword) |
C++17 |
|
105 ms |
35300 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 = 6;
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);
}
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';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
17300 KB |
Output is correct |
2 |
Correct |
100 ms |
17344 KB |
Output is correct |
3 |
Correct |
93 ms |
17376 KB |
Output is correct |
4 |
Correct |
105 ms |
17488 KB |
Output is correct |
5 |
Correct |
103 ms |
17640 KB |
Output is correct |
6 |
Correct |
103 ms |
17596 KB |
Output is correct |
7 |
Correct |
91 ms |
17360 KB |
Output is correct |
8 |
Correct |
94 ms |
17580 KB |
Output is correct |
9 |
Correct |
96 ms |
17360 KB |
Output is correct |
10 |
Correct |
92 ms |
17392 KB |
Output is correct |
11 |
Correct |
100 ms |
17332 KB |
Output is correct |
12 |
Correct |
91 ms |
17292 KB |
Output is correct |
13 |
Correct |
99 ms |
17388 KB |
Output is correct |
14 |
Correct |
104 ms |
17284 KB |
Output is correct |
15 |
Correct |
93 ms |
17308 KB |
Output is correct |
16 |
Correct |
93 ms |
17620 KB |
Output is correct |
17 |
Correct |
98 ms |
17544 KB |
Output is correct |
18 |
Correct |
94 ms |
17548 KB |
Output is correct |
19 |
Correct |
96 ms |
17548 KB |
Output is correct |
20 |
Correct |
96 ms |
17588 KB |
Output is correct |
21 |
Correct |
102 ms |
17320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
17300 KB |
Output is correct |
2 |
Correct |
100 ms |
17344 KB |
Output is correct |
3 |
Correct |
93 ms |
17376 KB |
Output is correct |
4 |
Correct |
105 ms |
17488 KB |
Output is correct |
5 |
Correct |
103 ms |
17640 KB |
Output is correct |
6 |
Correct |
103 ms |
17596 KB |
Output is correct |
7 |
Correct |
91 ms |
17360 KB |
Output is correct |
8 |
Correct |
94 ms |
17580 KB |
Output is correct |
9 |
Correct |
96 ms |
17360 KB |
Output is correct |
10 |
Correct |
92 ms |
17392 KB |
Output is correct |
11 |
Correct |
100 ms |
17332 KB |
Output is correct |
12 |
Correct |
91 ms |
17292 KB |
Output is correct |
13 |
Correct |
99 ms |
17388 KB |
Output is correct |
14 |
Correct |
104 ms |
17284 KB |
Output is correct |
15 |
Correct |
93 ms |
17308 KB |
Output is correct |
16 |
Correct |
93 ms |
17620 KB |
Output is correct |
17 |
Correct |
98 ms |
17544 KB |
Output is correct |
18 |
Correct |
94 ms |
17548 KB |
Output is correct |
19 |
Correct |
96 ms |
17548 KB |
Output is correct |
20 |
Correct |
96 ms |
17588 KB |
Output is correct |
21 |
Correct |
102 ms |
17320 KB |
Output is correct |
22 |
Runtime error |
99 ms |
35300 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
17300 KB |
Output is correct |
2 |
Correct |
100 ms |
17344 KB |
Output is correct |
3 |
Correct |
93 ms |
17376 KB |
Output is correct |
4 |
Correct |
105 ms |
17488 KB |
Output is correct |
5 |
Correct |
103 ms |
17640 KB |
Output is correct |
6 |
Correct |
103 ms |
17596 KB |
Output is correct |
7 |
Correct |
91 ms |
17360 KB |
Output is correct |
8 |
Correct |
94 ms |
17580 KB |
Output is correct |
9 |
Correct |
96 ms |
17360 KB |
Output is correct |
10 |
Correct |
92 ms |
17392 KB |
Output is correct |
11 |
Correct |
100 ms |
17332 KB |
Output is correct |
12 |
Correct |
91 ms |
17292 KB |
Output is correct |
13 |
Correct |
99 ms |
17388 KB |
Output is correct |
14 |
Correct |
104 ms |
17284 KB |
Output is correct |
15 |
Correct |
93 ms |
17308 KB |
Output is correct |
16 |
Correct |
93 ms |
17620 KB |
Output is correct |
17 |
Correct |
98 ms |
17544 KB |
Output is correct |
18 |
Correct |
94 ms |
17548 KB |
Output is correct |
19 |
Correct |
96 ms |
17548 KB |
Output is correct |
20 |
Correct |
96 ms |
17588 KB |
Output is correct |
21 |
Correct |
102 ms |
17320 KB |
Output is correct |
22 |
Runtime error |
99 ms |
35300 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
17300 KB |
Output is correct |
2 |
Correct |
100 ms |
17344 KB |
Output is correct |
3 |
Correct |
93 ms |
17376 KB |
Output is correct |
4 |
Correct |
105 ms |
17488 KB |
Output is correct |
5 |
Correct |
103 ms |
17640 KB |
Output is correct |
6 |
Correct |
103 ms |
17596 KB |
Output is correct |
7 |
Correct |
91 ms |
17360 KB |
Output is correct |
8 |
Correct |
94 ms |
17580 KB |
Output is correct |
9 |
Correct |
96 ms |
17360 KB |
Output is correct |
10 |
Correct |
92 ms |
17392 KB |
Output is correct |
11 |
Correct |
100 ms |
17332 KB |
Output is correct |
12 |
Correct |
91 ms |
17292 KB |
Output is correct |
13 |
Correct |
99 ms |
17388 KB |
Output is correct |
14 |
Correct |
104 ms |
17284 KB |
Output is correct |
15 |
Correct |
93 ms |
17308 KB |
Output is correct |
16 |
Correct |
93 ms |
17620 KB |
Output is correct |
17 |
Correct |
98 ms |
17544 KB |
Output is correct |
18 |
Correct |
94 ms |
17548 KB |
Output is correct |
19 |
Correct |
96 ms |
17548 KB |
Output is correct |
20 |
Correct |
96 ms |
17588 KB |
Output is correct |
21 |
Correct |
102 ms |
17320 KB |
Output is correct |
22 |
Runtime error |
99 ms |
35300 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |