mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 18:28:47 +00:00
#1745. 【2022.11.8 NOIP 模拟赛】石蒜反冲(lycoris)
https://sjzezoj.com/submission/63909
This commit is contained in:
parent
0a6f04d059
commit
e689335869
68
S2OJ/1745/1745.cpp
Normal file
68
S2OJ/1745/1745.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 10005,
|
||||
K = 2005;
|
||||
const int mod = 993244353;
|
||||
|
||||
const std::string s1 = "sakana";
|
||||
const std::string s2 = "chinanago";
|
||||
|
||||
int n, k, _f[N][K], *f[N];
|
||||
std::string s;
|
||||
|
||||
bool check(const std::string &pat, const std::string &str) {
|
||||
if (pat.size() != str.size()) return false;
|
||||
|
||||
for (int i = 0; i < pat.size(); i++) {
|
||||
if (pat[i] != '?' && pat[i] != str[i]) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> s;
|
||||
|
||||
k = n / std::max(s1.size(), s2.size());
|
||||
s = ' ' + s;
|
||||
|
||||
for (int i = 0; i <= n; i++) {
|
||||
f[i] = _f[i] + k + 1;
|
||||
}
|
||||
|
||||
f[0][0] = 1;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = -k; j <= k; j++) {
|
||||
if (s[i] == '?') f[i][j] = (f[i][j] + static_cast<long long>(f[i - 1][j]) * 26 % mod) % mod;
|
||||
else f[i][j] = f[i - 1][j];
|
||||
}
|
||||
|
||||
if (i >= s1.size() && check(s.substr(i - s1.size() + 1, s1.size()), s1)) {
|
||||
for (int j = -k; j <= k; j++) {
|
||||
f[i][j] = ((f[i][j] - f[i - s1.size()][j]) % mod + mod) % mod;
|
||||
f[i][j + 1] = (f[i][j + 1] + f[i - s1.size()][j]) % mod;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= s2.size() && check(s.substr(i - s2.size() + 1, s2.size()), s2)) {
|
||||
for (int j = -k; j <= k; j++) {
|
||||
f[i][j] = ((f[i][j] - f[i - s2.size()][j]) % mod + mod) % mod;
|
||||
f[i][j - 1] = (f[i][j - 1] + f[i - s2.size()][j]) % mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << f[n][0] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1745/data/ex_lycoris1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/ex_lycoris1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/ex_lycoris2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/ex_lycoris2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/ex_lycoris3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/ex_lycoris3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/ex_lycoris4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/ex_lycoris4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/ex_lycoris5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/ex_lycoris5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/ex_lycoris5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris11.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris11.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris12.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris12.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris13.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris13.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/lycoris9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/lycoris9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1745/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1745/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user