답안 #276017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
276017 2020-08-20T09:43:13 Z egekabas Cubeword (CEOI19_cubeword) C++14
0 / 100
36 ms 9640 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
const ll mod = 998244353;
ll ans = 0;
vector<string> a[11];
const ll n = 62;
ll cnt[8][70][70];
map<char, ll> mpp;
ll dp[70][70][70];
    
    
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        a[s.size()-3].pb(s);
    }
    int curcnt = 0;
    for(char i = 'a'; i <= 'z'; ++i)
        mpp[i] = curcnt++;
    for(char i = 'A'; i <= 'Z'; ++i)
        mpp[i] = curcnt++;
    for(char i = '0'; i <= '9'; ++i)
        mpp[i] = curcnt++;


    for(int cur = 0; cur < 8; ++cur){
        int sz = a[cur].size();
        for(int i = 0;  i < sz; ++i){
            string u = a[cur][i];
            reverse(all(u));
            a[cur].pb(u);
        }
        sort(all(a[cur]));
        for(int i = 0; i < a[cur].size(); ++i){
            if(i != 0 || a[cur][i] != a[cur][i-1])
                cnt[cur][mpp[a[cur][i][0]]][mpp[a[cur][i].back()]]++;
        }
    }
    for(int cur = 0; cur < 8; ++cur){
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j)
                for(int k = 0; k < n; ++k){
                    dp[i][j][k] = 0;
                    for(int mid = 0; mid < n; ++mid){
                        dp[i][j][k] += cnt[cur][i][mid]*cnt[cur][j][mid]*cnt[cur][k][mid]%mod;
                        if(dp[i][j][k] >= mod)
                            dp[i][j][k] -= mod;
                    }
                }
        for(int i = 0; i < n; ++i)
            for(int k = 0; k < n; ++k)
                for(int y = 0; y < n; ++y)
                    for(int j = 0; j < n; ++j){
                        ans += dp[i][k][j]*dp[i][j][y]%mod*dp[y][j][k]%mod*dp[i][k][y]%mod;
                        if(ans >= mod)
                            ans -= mod;
                    }
    }
    cout << ans << '\n';
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:56:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         for(int i = 0; i < a[cur].size(); ++i){
      |                        ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 9640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 9640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 9640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 9640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -