mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 21:28:48 +00:00
parent
77ce5fd3ac
commit
25a54d4d33
58
S2OJ/1899/1899.cpp
Normal file
58
S2OJ/1899/1899.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 505;
|
||||
const int mod = 1024523;
|
||||
|
||||
int n, m, f[2][N][N]{1};
|
||||
std::string a, b;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m >> a >> b;
|
||||
|
||||
std::reverse(a.begin(), a.end());
|
||||
std::reverse(b.begin(), b.end());
|
||||
|
||||
a = ' ' + a;
|
||||
b = ' ' + b;
|
||||
|
||||
for (int k = 1; k <= n + m; k++) {
|
||||
int t = k & 1,
|
||||
p = t ^ 1;
|
||||
|
||||
memset(f[t], 0x00, sizeof(f[t]));
|
||||
|
||||
for (int i = std::max(0, k - m); i <= std::min(n, k); i++) {
|
||||
for (int j = std::max(0, k - m); j <= std::min(n, k); j++) {
|
||||
if (i && j && a[i] == a[j]) {
|
||||
f[t][i][j] = (f[t][i][j] + f[p][i - 1][j - 1]) % mod;
|
||||
}
|
||||
|
||||
if (i && k - j && a[i] == b[k - j]) {
|
||||
f[t][i][j] = (f[t][i][j] + f[p][i - 1][j]) % mod;
|
||||
}
|
||||
|
||||
if (k - i && j && b[k - i] == a[j]) {
|
||||
f[t][i][j] = (f[t][i][j] + f[p][i][j - 1]) % mod;
|
||||
}
|
||||
|
||||
if (k - i && k - j && b[k - i] == b[k - j]) {
|
||||
f[t][i][j] = (f[t][i][j] + f[p][i][j]) % mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << f[(n + m) & 1][n][n] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1899/data/data1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/data9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/data9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1899/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1899/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user