Submission #658471

#TimeUsernameProblemLanguageResultExecution timeMemory
658471mychecksedadCubeword (CEOI19_cubeword)C++17
Compilation error
0 ms0 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 = 6; ll dp[100][100]; vector<string> s[15]; bool is_palindrome(string &a){ bool ok = 1; for(int i = 0; i < a.length() / 2; ++i) ok &= (a[i] == a[a.length() - i - 1]); return ok; } void solve(){ cin >> n; for(int i = 0; i < n; ++i){ string a; cin >> a; for(char &c: a) if(!(c >= 'a' && c <= 'p')) c = 'p' + (c - 'A') + 1; s[a.length()].pb(a); } ll ans = 0; for(int i = 1; i < 15; ++i){ if(s[i].empty()) continue; ll x = 1; for(int j = 0; j < S; ++j) for(int k = 0; k < S; ++k) dp[j][k] = 0; for(auto a: s[i]){ if(is_palindrome(a)){ dp[a[0] - 'a'][a[0] - 'a']++; }else{ dp[a[0] - 'a'][a.back() - 'a']++; dp[a.back() - 'a'][a[0] - 'a']++; } } for(int left = 0; left < S*S; ++left){ int x = left % S, y = left / S; for(int right = 0; right < S*S; ++right){ int z = right % S, w = right / S; ll p = (dp[x][y] * dp[z][w]) % MOD; ll P = 0; for(int middle = 0; middle < S*S; ++middle){ int k = middle % S, l = middle / S; ll pp = ((dp[k][l] * dp[x][k]) % MO)D * dp[y][l] % MOD; ll ppp = (dp[z][k] * dp[w][l]) % MOD; (ppp *= pp) %= MOD; (P += ppp) %= MOD; } P %= MOD; (ans += (p * P) % MOD * P) %= 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; }

Compilation message (stderr)

cubeword.cpp: In function 'bool is_palindrome(std::string&)':
cubeword.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < a.length() / 2; ++i) ok &= (a[i] == a[a.length() - i - 1]);
      |                    ~~^~~~~~~~~~~~~~~~
cubeword.cpp: In function 'void solve()':
cubeword.cpp:59:54: error: 'MO' was not declared in this scope; did you mean 'M'?
   59 |                     ll pp = ((dp[k][l] * dp[x][k]) % MO)D * dp[y][l] % MOD;
      |                                                      ^~
      |                                                      M
cubeword.cpp:37:12: warning: unused variable 'x' [-Wunused-variable]
   37 |         ll x = 1;
      |            ^
cubeword.cpp: In function 'int main()':
cubeword.cpp:78:16: warning: unused variable 'aa' [-Wunused-variable]
   78 |     int T = 1, aa;
      |                ^~