# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
556666 | fatemetmhr | Cubeword (CEOI19_cubeword) | C++17 | 985 ms | 26248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// ~~ Be name khoda ~~ //
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
const int al = 65;
const int szz = 10;
const int mod = 998244353;
const int maxn5 = 1e5 + 10;
set <string> av;
int id[maxn5];
int have[al][al][al][szz];
int cnt[szz][al][al];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n; cin >> n;
for(int i = 0; i < n; i++){
string s; cin >> s;
av.insert(s);
reverse(all(s));
av.insert(s);
}
int ind = 0;
for(int i = 0; i < 26; i++){
id[i + 'a'] = ind++;
id[i + 'A'] = ind++;
if(i < 10)
id[i + '0'] = ind++;
}
for(auto it = av.begin(); it != av.end(); it++){
string s = (*it);
cnt[s.size() - 3][id[s[0]]][id[s[s.size() - 1]]]++;
}
for(int i = 0; i < ind; i++) for(int j = i; j < ind; j++)
for(int k = j; k < ind; k++) for(int sz = 0; sz <= 8; sz++){
for(int z = 0; z < ind; z++)
have[i][j][k][sz] = (have[i][j][k][sz] + (ll(cnt[sz][i][z]) * cnt[sz][j][z] % mod) * cnt[sz][k][z]) % mod;
have[i][k][j][sz] = have[j][i][k][sz] = have[j][k][i][sz] = have[k][i][j][sz] = have[k][j][i][sz] = have[i][j][k][sz];
}
ll ans = 0;
for(int i = 0; i < ind; i++) for(int j = 0; j < ind; j++)
for(int k = 0; k < ind; k++) for(int z = 0; z < ind; z++) for(int sz = 0; sz <= 8; sz++)
ans = (ans + ((ll(have[i][j][k][sz]) * have[i][j][z][sz] % mod) * have[i][k][z][sz] % mod) * have[j][k][z][sz]) % mod;
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |