Submission #00046
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include<bits/stdc++.h> using namespace std; #define lol long long #define INF INT_MAX #define P pair<int,int> #define Pci pair<char,int> #define Pll pair<lol,lol> #define fi first #define se second #define mp(f,s) make_pair(f,s) const int mod = (1e9) + 7; // const int mod = 998244353; int main(){ string t,b; cin>>t>>b; // dp[i][j] ; t(石版)のi文字目までで、b(呪文)のj文字目まで完成する数 vector<vector< int >> dp(t.size() + 10,vector< int >(b.size() + 10,0)); for ( int i=0;i<t.size();i++){ for ( int j=0;j<b.size() && j <= i;j++){ if (t[i] == b[j]){ if (i == 0){ dp[i][j] = 1; } else { if (j == 0){ dp[i][j] += dp[i - 1][j] + 1; } else { dp[i][j] += dp[i - 1][j] + dp[i - 1][j - 1]; } } } else { if (i > 0){ dp[i][j] = dp[i - 1][j]; } } dp[i][j] %= mod; } } cout<<dp[t.size() - 1][b.size() - 1]<< "\n" ; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0007 - イワシロ・イッツァ |
ユーザー名 | ei2007 |
投稿日時 | 2022-07-19 16:22:32 |
言語 | C++17 |
状態 | Accepted |
得点 | 7 |
ソースコード長 | 1210 Byte |
最大実行時間 | 28 ms |
最大メモリ使用量 | 4628 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 7 / 7 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 28 ms | 472 KB |
1
|
in02.txt | AC | 22 ms | 432 KB |
1
|
in03.txt | AC | 19 ms | 532 KB |
1
|
in04.txt | AC | 17 ms | 628 KB |
1
|
in05.txt | AC | 17 ms | 636 KB |
1
|
in06.txt | AC | 20 ms | 516 KB |
1
|
in07.txt | AC | 23 ms | 660 KB |
1
|
in08.txt | AC | 28 ms | 504 KB |
1
|
in09.txt | AC | 24 ms | 476 KB |
1
|
in10.txt | AC | 23 ms | 444 KB |
1
|
in11.txt | AC | 24 ms | 1948 KB |
1
|
in12.txt | AC | 27 ms | 4480 KB |
1
|
in13.txt | AC | 19 ms | 2600 KB |
1
|
in14.txt | AC | 16 ms | 1928 KB |
1
|
in15.txt | AC | 19 ms | 4456 KB |
1
|
in16.txt | AC | 26 ms | 4628 KB |
1
|
in17.txt | AC | 24 ms | 576 KB |
1
|
in18.txt | AC | 19 ms | 620 KB |
1
|
in19.txt | AC | 21 ms | 628 KB |
1
|
in20.txt | AC | 22 ms | 648 KB |
1
|
in21.txt | AC | 21 ms | 644 KB |
1
|
in22.txt | AC | 19 ms | 608 KB |
1
|
in23.txt | AC | 26 ms | 680 KB |
1
|