Submission #447036

# Submission time Handle Problem Language Result Execution time Memory
447036 2021-07-24T09:34:42 Z yungyao Cubeword (CEOI19_cubeword) C++17
50 / 100
1100 ms 15692 KB
using namespace std;
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <utility>
#include <memory.h>
#include <vector>
#include <bitset>

typedef pair<int,int> pii;
typedef long long LL;

#define iter(x) x.begin(),x.end()
#define F first
#define S second
#define pb push_back
#define mkp make_pair

#include <climits>
const int maxn = 70,mod = (119 << 23)^1;

int ctoi(char c){
    if (c >= 'a' and c <= 'p') return c - 'a';
    else if (c >= 'A' and c <= 'P') return c - 'A' + 16;
    else if (c > 'p' and c <= 'z') return c - 'p' + 31;
    else if (c > 'P' and c <= 'Z') return c - 'P' + 41;
    else return c - '0' + 52;
}

LL cnt[maxn][maxn];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    set <string> st[11];
    int n;

    cin >> n;
    for (int i=0;i<n;++i){
        string s; cin >> s;
        st[s.size()].insert(s);
        reverse(iter(s));
        st[s.size()].insert(s);
    }

    LL ans = 0;
    for (int len=3;len<=10;++len) if (!st[len].empty()){
        int mx = 0;
        for (string s:st[len]){
            ++cnt[ctoi(s[0])][ctoi(s.back())];
            mx = max(mx,ctoi(s[0]));
        }
        for (int i=0;i<=mx;++i) for (int j=0;j<=mx;++j) for (int k=0;k<=mx;++k) for (int l=0;l<=mx;++l){
            LL c[4]{};
            for (int p=0;p<=mx;++p){
                c[0] += (cnt[i][p] * cnt[j][p]) % mod * cnt[k][p];
                c[0] %= mod;
            }
            for (int p=0;p<=mx;++p){
                c[1] += (cnt[i][p] * cnt[j][p]) % mod * cnt[l][p];
                c[1] %= mod;
            }
            for (int p=0;p<=mx;++p){
                c[2] += (cnt[i][p] * cnt[k][p]) % mod * cnt[l][p];
                c[2] %= mod;
            }
            for (int p=0;p<=mx;++p){
                c[3] += (cnt[j][p] * cnt[k][p]) % mod * cnt[l][p];
                c[3] %= mod;
            }
            c[0] *= c[1]; c[0] %= mod;
            c[0] *= c[2]; c[0] %= mod;
            c[0] *= c[3]; c[0] %= mod;
            ans = (ans + c[0]) % mod;
        }
        for (int i=0;i<=mx;++i) for (int j=0;j<=mx;++j) cnt[i][j] = 0;
    }

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 172 ms 14916 KB Output is correct
2 Correct 161 ms 14784 KB Output is correct
3 Correct 155 ms 14788 KB Output is correct
4 Correct 162 ms 14848 KB Output is correct
5 Correct 195 ms 14872 KB Output is correct
6 Correct 158 ms 14668 KB Output is correct
7 Correct 158 ms 14684 KB Output is correct
8 Correct 165 ms 14744 KB Output is correct
9 Correct 164 ms 14788 KB Output is correct
10 Correct 159 ms 14680 KB Output is correct
11 Correct 159 ms 14788 KB Output is correct
12 Correct 159 ms 14772 KB Output is correct
13 Correct 174 ms 14752 KB Output is correct
14 Correct 156 ms 14708 KB Output is correct
15 Correct 172 ms 14792 KB Output is correct
16 Correct 178 ms 14780 KB Output is correct
17 Correct 183 ms 14680 KB Output is correct
18 Correct 186 ms 14788 KB Output is correct
19 Correct 172 ms 14660 KB Output is correct
20 Correct 171 ms 14708 KB Output is correct
21 Correct 168 ms 14660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 172 ms 14916 KB Output is correct
2 Correct 161 ms 14784 KB Output is correct
3 Correct 155 ms 14788 KB Output is correct
4 Correct 162 ms 14848 KB Output is correct
5 Correct 195 ms 14872 KB Output is correct
6 Correct 158 ms 14668 KB Output is correct
7 Correct 158 ms 14684 KB Output is correct
8 Correct 165 ms 14744 KB Output is correct
9 Correct 164 ms 14788 KB Output is correct
10 Correct 159 ms 14680 KB Output is correct
11 Correct 159 ms 14788 KB Output is correct
12 Correct 159 ms 14772 KB Output is correct
13 Correct 174 ms 14752 KB Output is correct
14 Correct 156 ms 14708 KB Output is correct
15 Correct 172 ms 14792 KB Output is correct
16 Correct 178 ms 14780 KB Output is correct
17 Correct 183 ms 14680 KB Output is correct
18 Correct 186 ms 14788 KB Output is correct
19 Correct 172 ms 14660 KB Output is correct
20 Correct 171 ms 14708 KB Output is correct
21 Correct 168 ms 14660 KB Output is correct
22 Correct 324 ms 15692 KB Output is correct
23 Correct 309 ms 15448 KB Output is correct
24 Correct 309 ms 15428 KB Output is correct
25 Correct 314 ms 15360 KB Output is correct
26 Correct 316 ms 15428 KB Output is correct
27 Correct 319 ms 15444 KB Output is correct
28 Correct 330 ms 15372 KB Output is correct
29 Correct 317 ms 15428 KB Output is correct
30 Correct 337 ms 15380 KB Output is correct
31 Correct 333 ms 15556 KB Output is correct
32 Correct 308 ms 15352 KB Output is correct
33 Correct 310 ms 15444 KB Output is correct
34 Correct 315 ms 15492 KB Output is correct
35 Correct 313 ms 15420 KB Output is correct
36 Correct 306 ms 15456 KB Output is correct
37 Correct 305 ms 15428 KB Output is correct
38 Correct 306 ms 15436 KB Output is correct
39 Correct 308 ms 15548 KB Output is correct
40 Correct 305 ms 15352 KB Output is correct
41 Correct 312 ms 15524 KB Output is correct
42 Correct 324 ms 15440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 172 ms 14916 KB Output is correct
2 Correct 161 ms 14784 KB Output is correct
3 Correct 155 ms 14788 KB Output is correct
4 Correct 162 ms 14848 KB Output is correct
5 Correct 195 ms 14872 KB Output is correct
6 Correct 158 ms 14668 KB Output is correct
7 Correct 158 ms 14684 KB Output is correct
8 Correct 165 ms 14744 KB Output is correct
9 Correct 164 ms 14788 KB Output is correct
10 Correct 159 ms 14680 KB Output is correct
11 Correct 159 ms 14788 KB Output is correct
12 Correct 159 ms 14772 KB Output is correct
13 Correct 174 ms 14752 KB Output is correct
14 Correct 156 ms 14708 KB Output is correct
15 Correct 172 ms 14792 KB Output is correct
16 Correct 178 ms 14780 KB Output is correct
17 Correct 183 ms 14680 KB Output is correct
18 Correct 186 ms 14788 KB Output is correct
19 Correct 172 ms 14660 KB Output is correct
20 Correct 171 ms 14708 KB Output is correct
21 Correct 168 ms 14660 KB Output is correct
22 Correct 324 ms 15692 KB Output is correct
23 Correct 309 ms 15448 KB Output is correct
24 Correct 309 ms 15428 KB Output is correct
25 Correct 314 ms 15360 KB Output is correct
26 Correct 316 ms 15428 KB Output is correct
27 Correct 319 ms 15444 KB Output is correct
28 Correct 330 ms 15372 KB Output is correct
29 Correct 317 ms 15428 KB Output is correct
30 Correct 337 ms 15380 KB Output is correct
31 Correct 333 ms 15556 KB Output is correct
32 Correct 308 ms 15352 KB Output is correct
33 Correct 310 ms 15444 KB Output is correct
34 Correct 315 ms 15492 KB Output is correct
35 Correct 313 ms 15420 KB Output is correct
36 Correct 306 ms 15456 KB Output is correct
37 Correct 305 ms 15428 KB Output is correct
38 Correct 306 ms 15436 KB Output is correct
39 Correct 308 ms 15548 KB Output is correct
40 Correct 305 ms 15352 KB Output is correct
41 Correct 312 ms 15524 KB Output is correct
42 Correct 324 ms 15440 KB Output is correct
43 Execution timed out 1184 ms 15660 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 172 ms 14916 KB Output is correct
2 Correct 161 ms 14784 KB Output is correct
3 Correct 155 ms 14788 KB Output is correct
4 Correct 162 ms 14848 KB Output is correct
5 Correct 195 ms 14872 KB Output is correct
6 Correct 158 ms 14668 KB Output is correct
7 Correct 158 ms 14684 KB Output is correct
8 Correct 165 ms 14744 KB Output is correct
9 Correct 164 ms 14788 KB Output is correct
10 Correct 159 ms 14680 KB Output is correct
11 Correct 159 ms 14788 KB Output is correct
12 Correct 159 ms 14772 KB Output is correct
13 Correct 174 ms 14752 KB Output is correct
14 Correct 156 ms 14708 KB Output is correct
15 Correct 172 ms 14792 KB Output is correct
16 Correct 178 ms 14780 KB Output is correct
17 Correct 183 ms 14680 KB Output is correct
18 Correct 186 ms 14788 KB Output is correct
19 Correct 172 ms 14660 KB Output is correct
20 Correct 171 ms 14708 KB Output is correct
21 Correct 168 ms 14660 KB Output is correct
22 Correct 324 ms 15692 KB Output is correct
23 Correct 309 ms 15448 KB Output is correct
24 Correct 309 ms 15428 KB Output is correct
25 Correct 314 ms 15360 KB Output is correct
26 Correct 316 ms 15428 KB Output is correct
27 Correct 319 ms 15444 KB Output is correct
28 Correct 330 ms 15372 KB Output is correct
29 Correct 317 ms 15428 KB Output is correct
30 Correct 337 ms 15380 KB Output is correct
31 Correct 333 ms 15556 KB Output is correct
32 Correct 308 ms 15352 KB Output is correct
33 Correct 310 ms 15444 KB Output is correct
34 Correct 315 ms 15492 KB Output is correct
35 Correct 313 ms 15420 KB Output is correct
36 Correct 306 ms 15456 KB Output is correct
37 Correct 305 ms 15428 KB Output is correct
38 Correct 306 ms 15436 KB Output is correct
39 Correct 308 ms 15548 KB Output is correct
40 Correct 305 ms 15352 KB Output is correct
41 Correct 312 ms 15524 KB Output is correct
42 Correct 324 ms 15440 KB Output is correct
43 Execution timed out 1184 ms 15660 KB Time limit exceeded
44 Halted 0 ms 0 KB -