Submission #10237
ソースコード
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 | #include<bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int mul( int x, int y) { return (1LL * x * y % mod); } int main() { string S; int dp[202][203][2] = {{{}}}; cin >> S; for ( int i = 0; i < S.size(); i += 2) { dp[i][i + 1][S[i] == '1' ] = 1; } for ( int i = 3; i <= S.size(); i += 2) { for ( int j = 0; j + i <= S.size(); j += 2) { int L = j, R = j + i; for ( int k = L + 1; k < R; k += 2) { for ( int x = 0; x < 2; x++) { for ( int y = 0; y < 2; y++) { if (S[k] == '&' ) { (dp[L][R][x & y] += mul(dp[L][k][x], dp[k + 1][R][y])) %= mod; } else if (S[k] == '|' ) { (dp[L][R][x | y] += mul(dp[L][k][x], dp[k + 1][R][y])) %= mod; } else { (dp[L][R][x ^ y] += mul(dp[L][k][x], dp[k + 1][R][y])) %= mod; } } } } } } cout << dp[0][S.size()][1] << endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0570 - 1 |
ユーザー名 | root |
投稿日時 | 2016-11-11 12:41:08 |
言語 | C++11 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 979 Byte |
最大実行時間 | 27 ms |
最大メモリ使用量 | 908 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
00.in | AC | 23 ms | 732 KB |
1
|
01.in | AC | 18 ms | 908 KB |
1
|
02.in | AC | 27 ms | 696 KB |
1
|
03.in | AC | 17 ms | 740 KB |
1
|
04.in | AC | 27 ms | 788 KB |
1
|