Submission #00068
ソースコード
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 | #include<bits/stdc++.h> using namespace std; typedef pair< int , int > P; int n; string str; int dp[1010][10]; int solve( int day, int stu){ if (day == n) return 1; if (dp[day][stu] != -1) return dp[day][stu]; int next = 0; if (str[day] == 'J' ) next = 1; else if (str[day] == 'O' ) next = 2; else next = 4; int ret = 0; for ( int bit=0;bit<(1<<3);bit++){ if (!(next&bit)) continue ; if (!(bit&stu)) continue ; ret += solve(day+1,bit); } return dp[day][stu] = ret%10007; } int main(){ cin >> n; cin >> str; memset (dp,-1, sizeof (dp)); cout << solve(0,1) << endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - 部活のスケジュール表 (Schedule) |
ユーザー名 | ei1428 |
投稿日時 | 2016-12-02 16:19:48 |
言語 | C++11 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 618 Byte |
最大実行時間 | 25 ms |
最大メモリ使用量 | 648 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 | 14 ms | 476 KB |
1
|
2
|
3
|
4
|
5
|
2014-yo-t4-in2.txt | AC | 25 ms | 544 KB |
2
|
3
|
4
|
5
|
|
2014-yo-t4-in3.txt | AC | 16 ms | 484 KB |
3
|
4
|
5
|
||
2014-yo-t4-in4.txt | AC | 25 ms | 648 KB |
4
|
5
|
|||
2014-yo-t4-in5.txt | AC | 15 ms | 648 KB |
5
|