Submission #00003
ソースコード
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; const int MOD = 10007; int N; char str[1005]; int table[128]; int dp[1005][1 << 4]; int slv( int day, int bit) { if (day == N) { return 1; } if (~dp[day][bit]) return dp[day][bit]; int idx = table[str[day]]; //責任者のビットidx //if (bit == 0 || ((bit >> idx) & 1) == 0 ); int ret = 0; for ( int b = 1; b < 8; ++b) { int nxtBit = (bit & b); if (nxtBit == 0) continue ; if (!(b & (1<<idx))) continue ; ret = (ret + slv(day+1, b)) % MOD; } return dp[day][bit] = ret; } int main() { cin >> N >> str; table[ 'J' ] = 0; table[ 'O' ] = 1; table[ 'I' ] = 2; memset (dp, -1, sizeof (dp)); int ans = slv(0, 1); cout << ans << endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0002 - 部活のスケジュール表 (Schedule) |
ユーザー名 | 403号室 |
投稿日時 | 2018-11-06 21:31:03 |
言語 | C++14 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 826 Byte |
最大実行時間 | 33 ms |
最大メモリ使用量 | 664 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | 入力1 | 20 / 20 | *1.txt |
2 | 入力2 | 20 / 20 | *[12].txt |
3 | 入力3 | 20 / 20 | *[1-3].txt |
4 | 入力4 | 20 / 20 | *[1-4].txt |
5 | 入力5 | 20 / 20 | *[1-5].txt |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | ||||
---|---|---|---|---|---|---|---|---|
2014-yo-t4-in1.txt | AC | 33 ms | 604 KB |
1
|
2
|
3
|
4
|
5
|
2014-yo-t4-in2.txt | AC | 20 ms | 636 KB |
2
|
3
|
4
|
5
|
|
2014-yo-t4-in3.txt | AC | 19 ms | 544 KB |
3
|
4
|
5
|
||
2014-yo-t4-in4.txt | AC | 24 ms | 556 KB |
4
|
5
|
|||
2014-yo-t4-in5.txt | AC | 22 ms | 664 KB |
5
|