Submission #00194
ソースコード
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 | #include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; int solve( int n, int m ); string t, b; int dp[1001][1001]; int main() { for ( int i = 0; i < 1001; ++i ) { for ( int j = 0; j < 1001; ++j ) { dp[i][j] = -1; } } cin >> t >> b; printf ( "%d\n" , solve( 0, 0 ) ); return 0; } int solve( int n, int m ) { if ( dp[n][m] != - 1 ) return dp[n][m]; if ( m >= b.size() ) return 1; if ( n >= t.size() ) return 0; if ( t[n] == b[m] ) return dp[n][m] = ( solve( n + 1, m + 1 ) + solve( n + 1, m ) ) % MOD; return dp[n][m] = solve( n + 1, m ) % MOD; } |
ステータス
項目 | データ |
---|---|
問題 | 0007 - イワシロ・イッツァ |
ユーザー名 | UCS2 |
投稿日時 | 2018-08-07 11:41:45 |
言語 | C++11 |
状態 | Accepted |
得点 | 10 |
ソースコード長 | 688 Byte |
最大実行時間 | 35 ms |
最大メモリ使用量 | 4540 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 10 / 10 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 18 ms | 4320 KB |
1
|
in02.txt | AC | 21 ms | 4356 KB |
1
|
in03.txt | AC | 29 ms | 4512 KB |
1
|
in04.txt | AC | 35 ms | 4416 KB |
1
|
in05.txt | AC | 30 ms | 4532 KB |
1
|
in06.txt | AC | 26 ms | 4516 KB |
1
|
in07.txt | AC | 20 ms | 4504 KB |
1
|
in08.txt | AC | 25 ms | 4408 KB |
1
|
in09.txt | AC | 17 ms | 4308 KB |
1
|
in10.txt | AC | 28 ms | 4344 KB |
1
|
in11.txt | AC | 25 ms | 4504 KB |
1
|
in12.txt | AC | 27 ms | 4492 KB |
1
|
in13.txt | AC | 33 ms | 4476 KB |
1
|
in14.txt | AC | 25 ms | 4460 KB |
1
|
in15.txt | AC | 27 ms | 4448 KB |
1
|
in16.txt | AC | 21 ms | 4432 KB |
1
|
in17.txt | AC | 30 ms | 4416 KB |
1
|
in18.txt | AC | 28 ms | 4440 KB |
1
|
in19.txt | AC | 23 ms | 4424 KB |
1
|
in20.txt | AC | 22 ms | 4536 KB |
1
|
in21.txt | AC | 28 ms | 4524 KB |
1
|
in22.txt | AC | 23 ms | 4512 KB |
1
|
in23.txt | AC | 29 ms | 4540 KB |
1
|