Open tipstar0125 opened 1 year ago
input! {
S: Chars
}
let T = "chokudai".chars().collect_vec();
let mut dp = vec![vec![Mod::zero(); T.len() + 1]; S.len() + 1];
for i in 0..=S.len() {
dp[i][0] = Mod::one();
}
for i in 1..=S.len() {
let s = S[i - 1];
for j in 1..=T.len() {
let t = T[j - 1];
dp[i][j] = dp[i - 1][j];
if s == t {
let z = dp[i - 1][j - 1];
dp[i][j] += z;
}
}
}
println!("{}", dp[S.len()][T.len()].value());
https://atcoder.jp/contests/abc211/tasks/abc211_c https://atcoder.jp/contests/abc211/submissions/47585101