Submission #00189
ソースコード
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #include <bits/stdc++.h> using namespace std; #define MOD 10000000007 typedef long long ll; ll gcd( ll x, ll y ); ll lcm( ll x, ll y ); bool IsPrime( ll n ); int solve( int n, int m ); string t, b; ll 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; } ll gcd( ll x, ll y ) { if ( y == 0 ) return x; return gcd( y, x % y ); } ll lcm( ll x, ll y ) { return x / gcd( x, y ) * y; } bool IsPrime( ll n ) { if ( n < 2 ) return false ; else if ( n == 2 ) return true ; else if ( n % 2 == 0 ) return false ; for ( ll i = 3; i <= sqrt ( n ); i += 2 ) { if ( n % i == 0 ) return false ; } return true ; } 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:36:58 |
言語 | C++11 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 1167 Byte |
最大実行時間 | 38 ms |
最大メモリ使用量 | 8536 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 10 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 25 ms | 8284 KB |
1
|
in02.txt | AC | 25 ms | 8244 KB |
1
|
in03.txt | AC | 26 ms | 8328 KB |
1
|
in04.txt | AC | 26 ms | 8152 KB |
1
|
in05.txt | AC | 26 ms | 8320 KB |
1
|
in06.txt | WA | 27 ms | 8236 KB |
1
|
in07.txt | AC | 29 ms | 8276 KB |
1
|
in08.txt | AC | 23 ms | 8360 KB |
1
|
in09.txt | AC | 24 ms | 8316 KB |
1
|
in10.txt | AC | 21 ms | 8276 KB |
1
|
in11.txt | WA | 32 ms | 8352 KB |
1
|
in12.txt | AC | 33 ms | 8384 KB |
1
|
in13.txt | WA | 31 ms | 8424 KB |
1
|
in14.txt | WA | 30 ms | 8464 KB |
1
|
in15.txt | AC | 38 ms | 8372 KB |
1
|
in16.txt | AC | 27 ms | 8536 KB |
1
|
in17.txt | AC | 21 ms | 8444 KB |
1
|
in18.txt | AC | 26 ms | 8400 KB |
1
|
in19.txt | AC | 28 ms | 8436 KB |
1
|
in20.txt | WA | 27 ms | 8476 KB |
1
|
in21.txt | WA | 21 ms | 8512 KB |
1
|
in22.txt | WA | 28 ms | 8424 KB |
1
|
in23.txt | WA | 23 ms | 8508 KB |
1
|