Submission #556665

# Submission time Handle Problem Language Result Execution time Memory
556665 2022-05-03T13:45:28 Z fatemetmhr Cubeword (CEOI19_cubeword) C++17
0 / 100
1100 ms 24920 KB
// ~~ Be name khoda ~~ //

#include <bits/stdc++.h>


using namespace std;

typedef long long ll;

#define all(x)    x.begin(), x.end()
#define fi        first
#define se        second
#define pb        push_back

const int al    = 65;
const int szz   = 10;
const int mod   = 998244353;
const int maxn5 = 1e5 + 10;


set <string> av;
int id[maxn5];
int have[al][al][al][szz];
int cnt[szz][al][al];


int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n; cin >> n;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        av.insert(s);
        reverse(all(s));
        av.insert(s);
    }

    int ind = 0;

    for(int i = 0; i < 26; i++){
        id[i + 'a'] = ind++;
        id[i + 'A'] = ind++;
        if(i < 10)
            id[i + '0'] = ind++;
    }

    for(auto it = av.begin(); it != av.end(); it++){
        string s = (*it);
        cnt[s.size() - 3][id[s[0]]][id[s[s.size() - 1]]]++;
    }

    for(int i = 0; i < ind; i++) for(int j = i; j < ind; j++) 
        for(int k = j; k < ind; k++) for(int sz = 0; sz <= 8; sz++){
            for(int z = 0; z < ind; z++)
                have[i][j][k][sz] = (have[i][j][k][sz] + (ll(cnt[sz][i][z]) * cnt[sz][j][z] % mod) * cnt[sz][k][z]) % mod;
            have[i][k][j][sz] = have[j][i][k][sz] = have[j][k][i][sz] = have[k][i][j][sz] = have[k][j][i][sz] = have[i][j][k][sz];
        }
    ll ans = 0;
    for(int i = 0; i < ind; i++) for(int j = 0; j < ind; j++)
        for(int k = 0; k < ind; k++) for(int z = 0; z < ind; z++) for(int sz = 0; sz <= 8; sz++)
            ans = (ans + ((ll(have[i][j][k][sz]) * have[i][j][z][sz] % mod) * have[i][k][z][sz] % mod) * have[j][k][z][sz]) % mod;
    cout << ans << endl;
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:49:34: warning: array subscript has type 'char' [-Wchar-subscripts]
   49 |         cnt[s.size() - 3][id[s[0]]][id[s[s.size() - 1]]]++;
      |                                  ^
cubeword.cpp:49:55: warning: array subscript has type 'char' [-Wchar-subscripts]
   49 |         cnt[s.size() - 3][id[s[0]]][id[s[s.size() - 1]]]++;
      |                                                       ^
# Verdict Execution time Memory Grader output
1 Correct 1072 ms 24920 KB Output is correct
2 Correct 1089 ms 24824 KB Output is correct
3 Correct 1068 ms 24880 KB Output is correct
4 Correct 1075 ms 24864 KB Output is correct
5 Correct 1061 ms 24880 KB Output is correct
6 Correct 1056 ms 24872 KB Output is correct
7 Execution timed out 1102 ms 24892 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1072 ms 24920 KB Output is correct
2 Correct 1089 ms 24824 KB Output is correct
3 Correct 1068 ms 24880 KB Output is correct
4 Correct 1075 ms 24864 KB Output is correct
5 Correct 1061 ms 24880 KB Output is correct
6 Correct 1056 ms 24872 KB Output is correct
7 Execution timed out 1102 ms 24892 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1072 ms 24920 KB Output is correct
2 Correct 1089 ms 24824 KB Output is correct
3 Correct 1068 ms 24880 KB Output is correct
4 Correct 1075 ms 24864 KB Output is correct
5 Correct 1061 ms 24880 KB Output is correct
6 Correct 1056 ms 24872 KB Output is correct
7 Execution timed out 1102 ms 24892 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1072 ms 24920 KB Output is correct
2 Correct 1089 ms 24824 KB Output is correct
3 Correct 1068 ms 24880 KB Output is correct
4 Correct 1075 ms 24864 KB Output is correct
5 Correct 1061 ms 24880 KB Output is correct
6 Correct 1056 ms 24872 KB Output is correct
7 Execution timed out 1102 ms 24892 KB Time limit exceeded
8 Halted 0 ms 0 KB -