제출 #658588

#제출 시각아이디문제언어결과실행 시간메모리
658588mychecksedadCubeword (CEOI19_cubeword)C++17
100 / 100
272 ms8168 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int ll; typedef long double ld; #define MOD1 (1000000000+7) #define MOD (998244353) #define PI 3.1415926535 #define pb push_back #define setp() cout << setprecision(15) #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " is " << x << '\n'; const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20; int n, S = 65, mul[8] = { 24, 12, 12, 4, 12, 6, 4, 1 }; ll dp[100][100], d[70][70][70]; vector<string> s[15]; bool is_palindrome(string &a){ bool ok = 1; int x = a.length(); for(int i = 0; i < x / 2; ++i) ok &= (a[i] == a[x - i - 1]); return ok; } int comb(int a, int b, int c, int d){ int q = 0; if(a==b) q += 1; if(b==c) q += 2; if(c==d) q += 4; return mul[q]; } void solve(){ cin >> n; for(int i = 0; i < n; ++i){ string a; cin >> a; for(char &c: a){ if(c >= 'a' && c <= 'z'){ c = '9' + 1 + (c - 'a'); } else if(c >= 'A' && c <= 'Z'){ c = '9' + 27 + (c - 'A'); } } s[a.length()].pb(a); } ll ans = 0; for(int i = 1; i < 15; ++i){ if(s[i].empty()) continue; for(int j = 0; j < S; ++j) for(int k = 0; k < S; ++k) dp[j][k] = 0; map<string, bool> used; for(auto a: s[i]){ if(used[a]) continue; if(is_palindrome(a)){ dp[a[0] - '0'][a[0] - '0']++; }else{ dp[a[0] - '0'][a.back() - '0']++; dp[a.back() - '0'][a[0] - '0']++; } reverse(all(a)); used[a] = 1; } for(int a = 0; a < S; ++a){ for(int b = a; b < S; ++b){ for(int c = b; c < S; ++c){ d[a][b][c] = 0; for(int l = 0; l < S; ++l){ (d[a][b][c] += (dp[a][l] * dp[b][l] % MOD) * dp[c][l]) %= MOD; } } } } for(int a = 0; a < S; ++a){ for(int b = a; b < S; ++b){ for(int c = b; c < S; ++c){ for(int e = c; e < S; ++e){ ll p = (d[a][b][c] * d[a][b][e] % MOD) * (d[a][c][e] * d[b][c][e] % MOD) % MOD; (ans += p * comb(a, b, c, e)) %= MOD; } } } } } cout << ans; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int T = 1, aa; // cin >> T;aa=T; while(T--){ // cout << "Case #" << aa-T << ": "; solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

cubeword.cpp: In function 'int main()':
cubeword.cpp:101:16: warning: unused variable 'aa' [-Wunused-variable]
  101 |     int T = 1, aa;
      |                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...