이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#define rep(i, a, b) for(signed i = a; i <= b; i++)
#define rrep(i, a, b) for(signed i = b; i >= a; i--)
#define ceil(a, b) ((a + b - 1) / (b))
#define all(x) x.begin(), x.end()
#define INF 1000000000000000000
#define eps (1e-9)
using namespace std;
#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
namespace solver {
const int P = 16, MOD = 998244353;
signed cnt[11][70][70];
int dp[11][70][70][70];
set<string> st;
void init_() {
st.clear();
}
int solve() {
int x = 0;
rep(len, 3, 10) rep(a, 0, P - 1)
rep(b, a, P - 1) rep(c, b, P - 1) {
int cur = 0;
rep(d, 0, P - 1) {
cur += cnt[len][d][a] * cnt[len][d][b] % MOD
*cnt[len][d][c] % MOD; x++;
}
cur %= MOD;
dp[len][a][b][c] = dp[len][b][c][a]
= dp[len][c][b][a] = dp[len][a][c][b]
= dp[len][c][a][b] = dp[len][b][a][c] = cur;
}
int ans = 0;
rep(len, 3, 10) rep(a, 0, P - 1) rep(b, 0, P - 1) {
rep(c, 0, P - 1) rep(d, 0, P - 1) {
ans = ans + (dp[len][a][b][d] * dp[len][a][b][c] % MOD
* dp[len][a][c][d] % MOD * dp[len][b][c][d] % MOD);
x++;
}
ans %= MOD;
}
assert(x <= 1e7);
return ans;
}
void add(string s) {
int sz = s.size(), pre, suf;
if(isdigit(s[0])) pre = 52 + s[0] - '0';
if(islower(s[0])) pre = s[0] - 'a';
if(isupper(s[0])) pre = s[0] - 'A' + 26;
if(isdigit(s.back())) suf = 52 + s.back() - '0';
if(islower(s.back())) suf = s.back() - 'a';
if(isupper(s.back())) suf = s.back() - 'A' + 26;
cnt[sz][pre][suf] ++;
}
};
using namespace solver;
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int n; cin >> n;
init_();
rep(i, 1, n) {
string s, s1; cin >> s;
int sz = s.size();
if(st.find(s) == st.end()) add(s);
st.insert(s);
s1 = s, reverse(all(s1));
if(st.find(s1) == st.end()) add(s1);
st.insert(s1);
}
cout << solve() << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
cubeword.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
4 | #pragma loop-opt(on)
|
cubeword.cpp:22:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
22 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
cubeword.cpp:22:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
22 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
cubeword.cpp: In function 'int main()':
cubeword.cpp:82:7: warning: unused variable 'sz' [-Wunused-variable]
82 | int sz = s.size();
| ^~
cubeword.cpp: In function 'void solver::add(std::string)':
cubeword.cpp:72:19: warning: 'suf' may be used uninitialized in this function [-Wmaybe-uninitialized]
72 | cnt[sz][pre][suf] ++;
| ~~~~~~~~~~~~~~~~^
cubeword.cpp:72:19: warning: 'pre' may be used uninitialized in this function [-Wmaybe-uninitialized]
# | 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... |