QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401621#944. Cubewordnhuang685#21 143ms18316kbC++202.3kb2024-04-29 03:00:252024-04-29 03:00:25

Judging History

你现在查看的是最新测评结果

  • [2024-04-29 03:00:25]
  • 评测
  • 测评结果:21
  • 用时:143ms
  • 内存:18316kb
  • [2024-04-29 03:00:25]
  • 提交

answer

#include <bits/stdc++.h>

const int MOD = 998244353;
struct Mint {
  int val = 0;
  Mint(int v = 0) : val(v) {
    if (val <= -MOD || MOD <= val) {
      val %= MOD;
    }
    if (val < 0) {
      val += MOD;
    }
  }
  Mint &operator+=(Mint b) {
    val += b.val;
    if (val >= MOD) {
      val -= MOD;
    }
    return *this;
  }
  Mint &operator*=(Mint b) {
    val = (int)((int64_t)val * b.val % MOD);
    return *this;
  }
};
Mint operator+(Mint a, Mint b) { return a += b; }
Mint operator*(Mint a, Mint b) { return a *= b; }

const int MX = 6;
const int LEN = 10;

int main() {
  std::cin.tie(nullptr)->sync_with_stdio(false);

  int n;
  std::cin >> n;

  std::set<std::string> ss;
  std::vector freq(LEN + 1, std::vector(MX, std::vector<int>(MX)));
  for (int i = 0; i < n; ++i) {
    std::string s;
    std::cin >> s;
    int len = (int)s.size();
    int st = s[0] - 'a', en = s.back() - 'a';
    if (!ss.contains(s)) {
      freq[len][st][en]++;
    }
    ss.insert(s);
    std::string t = s;
    std::reverse(t.begin(), t.end());
    if (!ss.contains(t)) {
      freq[len][en][st]++;
    }
    ss.insert(t);
  }

  Mint ans = 0;
  for (int len = 3; len <= 10; ++len) {
    std::vector cur(MX,
                    std::vector(MX, std::vector(MX, std::vector<Mint>(MX))));
    std::vector pre = cur;
    for (int i = 0; i < MX; ++i) {
      for (int j = 0; j < MX; ++j) {
        pre[i][j][i][j] = freq[len][i][j];
      }
    }
    for (int i = 0; i < 4; ++i) {
      for (int a = 0; a < MX; ++a) {
        for (int b = 0; b < MX; ++b) {
          for (int c = 0; c < MX; ++c) {
            for (int d = 0; d < MX; ++d) {
              for (int e = 0; e < MX; ++e) {
                for (int f = 0; f < MX; ++f) {
                  cur[a][b][c][d] +=
                      freq[len][e][c] * freq[len][f][d] * pre[a][b][e][f];
                }
              }
              if (i < 3) {
                cur[a][b][c][d] *= freq[len][c][d];
              }
            }
          }
        }
      }
      std::swap(cur, pre);
      cur.assign(MX, std::vector(MX, std::vector(MX, std::vector<Mint>(MX))));
    }
    for (int i = 0; i < MX; ++i) {
      for (int j = 0; j < MX; ++j) {
        ans += pre[i][j][i][j];
      }
    }
  }
  std::cout << ans.val << '\n';
}

详细

Subtask #1:

score: 21
Accepted

Test #1:

score: 21
Accepted
time: 142ms
memory: 18032kb

input:

100000
aaa
aaaa
aaaaa
aaaaaacb
aaaaabfdab
aaaaacaeba
aaaaacbec
aaaaacc
aaaaacdde
aaaaad
aaaaaef
aaaaafe
aaaab
aaaaba
aaaabac
aaaabcab
aaaabdcab
aaaabddec
aaaabeabd
aaaabeeacc
aaaac
aaaacaafee
aaaacabec
aaaacad
aaaacb
aaaacbcbba
aaaacbddbe
aaaacc
aaaacdda
aaaacdf
aaaacecdca
aaaacfceed
aaaacfdef
aaaad...

output:

966519702

result:

ok 1 number(s): "966519702"

Test #2:

score: 0
Accepted
time: 128ms
memory: 18308kb

input:

99999
aaa
aaaa
aaaaa
aaaaaad
aaaaabcee
aaaaabecdc
aaaaabecf
aaaaacdfcc
aaaaad
aaaaadab
aaaaaecaab
aaaaaee
aaaaafafd
aaaaafccf
aaaab
aaaaba
aaaabad
aaaabada
aaaabc
aaaabcaecb
aaaabd
aaaabdfb
aaaabede
aaaabefedb
aaaabfeaa
aaaabffddb
aaaac
aaaacbbcc
aaaacbec
aaaaccb
aaaaccbfee
aaaaccde
aaaacceb
aaaacd
...

output:

884966963

result:

ok 1 number(s): "884966963"

Test #3:

score: 0
Accepted
time: 132ms
memory: 18028kb

input:

99998
aaa
aaaa
aaaaa
aaaaaaa
aaaaaae
aaaaac
aaaaaccb
aaaaadb
aaaaadcbd
aaaaafedd
aaaaaff
aaaab
aaaabadd
aaaabbeb
aaaabc
aaaabceca
aaaabcf
aaaabd
aaaabdce
aaaabe
aaaabf
aaaabfab
aaaabfad
aaaabfeffb
aaaac
aaaacaecbb
aaaacb
aaaacbdb
aaaacda
aaaacdd
aaaacdddaf
aaaace
aaaacecde
aaaacfeff
aaaacffe
aaaad
a...

output:

519865738

result:

ok 1 number(s): "519865738"

Test #4:

score: 0
Accepted
time: 143ms
memory: 18028kb

input:

99997
aaa
aaaa
aaaaa
aaaaaa
aaaaaac
aaaaaaed
aaaaab
aaaaac
aaaaad
aaaaadbdf
aaaaaf
aaaaafc
aaaaafe
aaaaaffebf
aaaab
aaaaba
aaaababaa
aaaababdca
aaaabacbcb
aaaabae
aaaabaeec
aaaabc
aaaabdb
aaaabddeab
aaaabfe
aaaac
aaaacbafdf
aaaacbfbcb
aaaaccfe
aaaacd
aaaacdfb
aaaacecfaa
aaaaceeea
aaaacfbaf
aaaacffb
...

output:

440905828

result:

ok 1 number(s): "440905828"

Test #5:

score: 0
Accepted
time: 142ms
memory: 18100kb

input:

99996
aaa
aaaa
aaaaa
aaaaaaea
aaaaab
aaaaabaf
aaaaabcb
aaaaac
aaaaacbcce
aaaaadb
aaaaadf
aaaaaeaf
aaaaaeb
aaaaaef
aaaaaefd
aaaaafeee
aaaab
aaaabaacca
aaaabb
aaaabbdd
aaaabc
aaaabcc
aaaabcdb
aaaabcdbbb
aaaabcdf
aaaabce
aaaabde
aaaabdefb
aaaac
aaaacaee
aaaacafa
aaaacb
aaaacbb
aaaaccebfc
aaaacd
aaaacdf...

output:

606830795

result:

ok 1 number(s): "606830795"

Test #6:

score: 0
Accepted
time: 140ms
memory: 18092kb

input:

99995
aaa
aaaa
aaaaa
aaaaaaa
aaaaaaabcf
aaaaaaaccf
aaaaaaafb
aaaaaad
aaaaaaf
aaaaab
aaaaabecfc
aaaaac
aaaaacbc
aaaaacc
aaaaaceee
aaaaacffc
aaaaad
aaaaadfccf
aaaaaec
aaaaaee
aaaaaefaec
aaaab
aaaabaffab
aaaabbaadc
aaaabbd
aaaabbed
aaaabdcebd
aaaabeacf
aaaabedfc
aaaabfcd
aaaabfe
aaaac
aaaaca
aaaacaf
aa...

output:

293744889

result:

ok 1 number(s): "293744889"

Test #7:

score: 0
Accepted
time: 125ms
memory: 18052kb

input:

99994
aaa
aaaa
aaaaa
aaaaaa
aaaaaaab
aaaaaabdd
aaaaacbfb
aaaaacfeef
aaaaadab
aaaaae
aaaaaeaf
aaaaaf
aaaaafac
aaaab
aaaababdb
aaaabb
aaaabbadf
aaaabbec
aaaabccc
aaaabde
aaaabdffbf
aaaabefdfa
aaaabff
aaaabffdf
aaaac
aaaacaf
aaaacafed
aaaacbeccd
aaaaccbbb
aaaacd
aaaacdba
aaaacddafb
aaaacdf
aaaacdfdc
aa...

output:

745454877

result:

ok 1 number(s): "745454877"

Test #8:

score: 0
Accepted
time: 129ms
memory: 18044kb

input:

99993
aaa
aaaa
aaaaaa
aaaaaaa
aaaaaabdf
aaaaabbee
aaaaac
aaaaaccfaf
aaaaadbece
aaaaafa
aaaaafacb
aaaab
aaaabadda
aaaabb
aaaabbacd
aaaabbea
aaaabcddb
aaaabdbff
aaaabfb
aaaabfee
aaaac
aaaaca
aaaacbbc
aaaacbecb
aaaacc
aaaaccbbec
aaaaccc
aaaacdcb
aaaacddd
aaaacdfcba
aaaaceae
aaaacecdfe
aaaacfc
aaaad
aaa...

output:

429068770

result:

ok 1 number(s): "429068770"

Test #9:

score: 0
Accepted
time: 136ms
memory: 18040kb

input:

99992
aaa
aaaa
aaaaa
aaaaaaccb
aaaaaacdef
aaaaaadfd
aaaaaafd
aaaaab
aaaaabd
aaaaabeee
aaaaacda
aaaaacf
aaaaad
aaaaadbca
aaaaaeed
aaaaafccfb
aaaab
aaaababb
aaaabaddb
aaaabafadc
aaaabbb
aaaabbd
aaaabcd
aaaabce
aaaabf
aaaabfa
aaaabfbf
aaaabfcac
aaaabfd
aaaabfde
aaaabff
aaaabffdc
aaaac
aaaaca
aaaacae
aa...

output:

289771162

result:

ok 1 number(s): "289771162"

Test #10:

score: 0
Accepted
time: 131ms
memory: 17988kb

input:

99991
aaa
aaaa
aaaaa
aaaaaaad
aaaaac
aaaaacecbf
aaaaacfa
aaaaadcdc
aaaaae
aaaab
aaaabafafe
aaaabee
aaaabeeb
aaaabf
aaaabfdcc
aaaacaeffe
aaaacc
aaaaccab
aaaacded
aaaace
aaaacea
aaaaceaad
aaaaceaecc
aaaacfeb
aaaacff
aaaad
aaaada
aaaadaf
aaaadba
aaaadbfe
aaaadc
aaaadcf
aaaadd
aaaaddae
aaaaddcf
aaaade
a...

output:

875542265

result:

ok 1 number(s): "875542265"

Test #11:

score: 0
Accepted
time: 141ms
memory: 18088kb

input:

99990
aaa
aaaa
aaaaa
aaaaaba
aaaaabdcd
aaaaac
aaaaacbfcf
aaaaada
aaaaaed
aaaaaeeec
aaaaafdc
aaaaaffadc
aaaab
aaaabaddd
aaaabceeeb
aaaabda
aaaabf
aaaabfaffe
aaaabfedcd
aaaac
aaaaca
aaaacab
aaaacabdfc
aaaacaf
aaaacbaea
aaaacbb
aaaacccbf
aaaaccecaf
aaaacdf
aaaacede
aaaaceebea
aaaaceeddd
aaaacfba
aaaad
...

output:

236060052

result:

ok 1 number(s): "236060052"

Test #12:

score: 0
Accepted
time: 141ms
memory: 18300kb

input:

99989
aaa
aaaa
aaaaa
aaaaaadfdd
aaaaabee
aaaaac
aaaaacbb
aaaaaed
aaaaaedbe
aaaaafae
aaaab
aaaababfa
aaaabacb
aaaabbcefd
aaaabc
aaaabccebb
aaaabeaea
aaaabeb
aaaabeca
aaaabed
aaaabedb
aaaabfaba
aaaabfbdb
aaaabfd
aaaabfdf
aaaabffeb
aaaac
aaaaca
aaaacad
aaaaccacbc
aaaaccafaa
aaaaccb
aaaacdccc
aaaacdff
a...

output:

382736648

result:

ok 1 number(s): "382736648"

Test #13:

score: 0
Accepted
time: 137ms
memory: 18032kb

input:

99988
aaa
aaaa
aaaaa
aaaaaacc
aaaaaaeef
aaaaab
aaaaabfbdc
aaaaabfdb
aaaaaccdca
aaaaacfbc
aaaaadf
aaaaaede
aaaaaf
aaaaafdbcd
aaaaafea
aaaab
aaaabbae
aaaabbbda
aaaabbd
aaaabbec
aaaabc
aaaabcacc
aaaabcaeca
aaaabce
aaaabdbae
aaaabdbb
aaaabee
aaaabfead
aaaabfeefb
aaaac
aaaacb
aaaacbbe
aaaacccfaa
aaaaccd
...

output:

778837075

result:

ok 1 number(s): "778837075"

Test #14:

score: 0
Accepted
time: 142ms
memory: 18316kb

input:

99987
aaa
aaaa
aaaaa
aaaaaabe
aaaaaacbbc
aaaaaacecf
aaaaaadc
aaaaaaeffd
aaaaab
aaaaabf
aaaaacab
aaaaaccbaf
aaaaacd
aaaaacdeca
aaaaacec
aaaaaceda
aaaaacf
aaaaadc
aaaaadefe
aaaaae
aaaaaeaab
aaaaafabe
aaaaafaf
aaaaafddad
aaaaaffccd
aaaab
aaaabafb
aaaabdbca
aaaabdebe
aaaabecca
aaaabfba
aaaabfbb
aaaabfbd...

output:

265167705

result:

ok 1 number(s): "265167705"

Test #15:

score: 0
Accepted
time: 142ms
memory: 18028kb

input:

99986
aaa
aaaa
aaaaa
aaaaaa
aaaaaaafc
aaaaaabcfa
aaaaaabdbb
aaaaaabfd
aaaaaadd
aaaaaadf
aaaaab
aaaaabbba
aaaaabcc
aaaaacebdd
aaaaad
aaaaaddbcb
aaaaaf
aaaaafa
aaaaafaaba
aaaaafea
aaaab
aaaababdc
aaaababfc
aaaabaccbe
aaaabb
aaaabbcb
aaaabbfecf
aaaabdad
aaaabe
aaaabecea
aaaabeddc
aaaabfdbec
aaaac
aaaac...

output:

376583661

result:

ok 1 number(s): "376583661"

Test #16:

score: 0
Accepted
time: 134ms
memory: 18124kb

input:

99985
aaa
aaaa
aaaaa
aaaaaa
aaaaaadaed
aaaaaae
aaaaabbdb
aaaaac
aaaaadadba
aaaaaeb
aaaaaefdd
aaaaafd
aaaaafe
aaaaaffde
aaaab
aaaababbda
aaaabace
aaaabaf
aaaabbfcf
aaaabcefad
aaaabdacfb
aaaabdef
aaaabe
aaaabeab
aaaabfd
aaaabfdbf
aaaac
aaaacbbef
aaaacc
aaaacd
aaaacdae
aaaacdfea
aaaace
aaaacec
aaaacfbf...

output:

546456611

result:

ok 1 number(s): "546456611"

Test #17:

score: 0
Accepted
time: 134ms
memory: 17980kb

input:

99984
aaa
aaaa
aaaaaaca
aaaaaaecf
aaaaabdde
aaaaabfc
aaaaacaefc
aaaaacbfed
aaaaacf
aaaaadcec
aaaaadeabf
aaaaafdee
aaaab
aaaabafecf
aaaabbe
aaaabdbde
aaaabebac
aaaabfe
aaaabffa
aaaac
aaaacbbdb
aaaacbe
aaaaccead
aaaacdaace
aaaacdaf
aaaacee
aaaacfa
aaaacfeae
aaaad
aaaada
aaaadaddbb
aaaadb
aaaadba
aaaad...

output:

82579691

result:

ok 1 number(s): "82579691"

Test #18:

score: 0
Accepted
time: 136ms
memory: 18088kb

input:

99983
aaa
aaaa
aaaaa
aaaaaab
aaaaac
aaaaaca
aaaaacbdd
aaaaad
aaaaadf
aaaaae
aaaaaeedbb
aaaaaf
aaaaafd
aaaaafda
aaaaba
aaaabaccb
aaaabada
aaaabafba
aaaabb
aaaabbb
aaaabcbf
aaaabcc
aaaabccea
aaaabceec
aaaabd
aaaabdaeaf
aaaabe
aaaabead
aaaabeafc
aaaabefc
aaaabefda
aaaabfdce
aaaaca
aaaacabfd
aaaacbaaf
a...

output:

843794331

result:

ok 1 number(s): "843794331"

Test #19:

score: 0
Accepted
time: 130ms
memory: 18272kb

input:

99982
aaa
aaaa
aaaaa
aaaaaa
aaaaabfcd
aaaaac
aaaaacc
aaaaacccde
aaaaae
aaaaaea
aaaaaeaa
aaaaaebce
aaaaaec
aaaaaf
aaaab
aaaabaa
aaaabac
aaaabae
aaaabbc
aaaabbdf
aaaabbf
aaaabc
aaaabddaf
aaaabdef
aaaabfdcc
aaaabfea
aaaabff
aaaac
aaaacab
aaaacb
aaaacbfe
aaaacc
aaaacca
aaaaccabe
aaaacd
aaaacdaefe
aaaacd...

output:

73145981

result:

ok 1 number(s): "73145981"

Test #20:

score: 0
Accepted
time: 137ms
memory: 18212kb

input:

99981
aaa
aaaa
aaaaa
aaaaaa
aaaaaaac
aaaaaba
aaaaacd
aaaaadf
aaaaaef
aaaaafae
aaaaaffd
aaaab
aaaabbaca
aaaabbedb
aaaabc
aaaabcc
aaaabccd
aaaabddd
aaaabebbca
aaaabebbe
aaaabebbea
aaaabec
aaaabece
aaaabedade
aaaabeee
aaaabfcba
aaaac
aaaacaacbc
aaaacbbeda
aaaacbe
aaaacbfbd
aaaacdd
aaaaceeaa
aaaacf
aaaa...

output:

328200997

result:

ok 1 number(s): "328200997"

Test #21:

score: 0
Accepted
time: 139ms
memory: 18020kb

input:

99980
aaa
aaaa
aaaaa
aaaaaa
aaaaaaa
aaaaab
aaaaabb
aaaaac
aaaaacfcab
aaaaaddd
aaaaadfa
aaaaaedfcc
aaaaaf
aaaab
aaaabaa
aaaabab
aaaabb
aaaabbd
aaaabbfcb
aaaabc
aaaabcaccd
aaaabd
aaaabdacd
aaaabde
aaaabeec
aaaac
aaaacabeff
aaaacadb
aaaacba
aaaacbc
aaaacbcbc
aaaacbd
aaaaceceef
aaaacf
aaaacfb
aaaacfcdec...

output:

975997785

result:

ok 1 number(s): "975997785"

Subtask #2:

score: 0
Runtime Error

Dependency #1:

100%
Accepted

Test #22:

score: 0
Runtime Error

input:

100000
aaa
aaaa
aaaadfnl
aaab
aaabf
aaabgbohpg
aaac
aaadhgjebb
aaadjfc
aaaeigcc
aaaekhec
aaafgb
aaaggn
aaagifb
aaahmjhb
aaaj
aaajokcjd
aaakaiojjl
aaakb
aaalgb
aaalpkf
aaam
aaamehmil
aaane
aaanmo
aaaobb
aaaogddkfh
aaap
aaapifl
aab
aaba
aabakfm
aabcb
aabcbhb
aabembjed
aabf
aabfmoppgf
aabh
aabhkj
aabhl...

output:


result:


Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%