Submission #844632

#TimeUsernameProblemLanguageResultExecution timeMemory
844632browntoadCubeword (CEOI19_cubeword)C++14
100 / 100
219 ms29280 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("Ofast", "unroll-loops") using namespace std; #define ll long long #define int ll #define FOR(i,a,b) for (int i = (a); i<(b); i++) #define REP(i,n) FOR(i,0,n) #define REP1(i,n) FOR(i,1,n+1) #define RREP(i,n) for (int i=(n)-1; i>=0; i--) #define RREP1(i, n) for (int i=(n); i>=1; i--) #define f first #define s second #define pb push_back #define ALL(x) x.begin(),x.end() #define SZ(x) (int)(x.size()) #define SQ(x) (x)*(x) #define pii pair<int, int> #define pip pair<int, pii> #define ppi pair<pii, int> #define ppp pair<pii, pii> #define pdd pair<double ,double> #define pcc pair<char, char> #define endl '\n' //#define TOAD #ifdef TOAD #define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl #define IOS() #else #define bug(...) #define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #endif const ll inf = 1ll<<60; const ll iinf = 2147483647; const ll mod = 998244353; const ll maxn=1e6+5; const double PI=acos(-1); ll pw(ll x, ll p, ll m=mod){ ll ret=1; while (p>0){ if (p&1){ ret*=x; ret%=m; } x*=x; x%=m; p>>=1; } return ret; } ll inv(ll a, ll m=mod){ return pw(a,m-2,m); } int n; int cnt[62][62][11]; int ou[62][62][62][11]; int cv(char k){ if (k>='a' && k<='z'){ return (k-'a'); } else if (k>='A' && k<='Z'){ return (k-'A')+26; } else return (k-'0')+52; } signed main(){ IOS(); cin>>n; map<string, bool> mp; REP(i, n){ string str; cin>>str; mp[str]=1; reverse(ALL(str)); mp[str]=1; } for (auto x:mp){ cnt[cv(x.f[0])][cv(x.f[SZ(x.f)-1])][SZ(x.f)]++; } int ans = 0; int tot = 0; FOR(l, 3, 11){ REP(i, 62){ FOR(j, i, 62){ FOR(k, j, 62){ REP(t, 62){ ou[i][j][k][l] += (cnt[i][t][l]*cnt[j][t][l]*cnt[k][t][l])%mod; if (ou[i][j][k][l] >= mod) ou[i][j][k][l] -= mod; } } } } int tmp; REP(a, 62){ FOR(b, a, 62){ FOR(c, b, 62){ FOR(d, c, 62){ tmp = ou[a][b][c][l]*ou[a][b][d][l]%mod*ou[a][c][d][l]%mod*ou[b][c][d][l]%mod; if (a == d); else if (a == c || b == d) tmp *= 4; else if (a == b && c == d) tmp *= 6; else if (a == b || b == c || c == d) tmp *= 12; else tmp *= 24; tot = (tot+tmp)%mod; } } } } } cout<<tot<<endl; }

Compilation message (stderr)

cubeword.cpp: In function 'int main()':
cubeword.cpp:81:9: warning: unused variable 'ans' [-Wunused-variable]
   81 |     int ans = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...