Submission #00128


ソースコード

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
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
#define int long long
int n,m;
cin >>n;
string s;
cin >>s;
vector<vector<int>>dp(n+1,vector<int>(8,0));
for(int i = 0;i < 8;i++){
if(i & 4)dp[0][i] = 1;
}
for(int i = 0;i < n;i++){
int x = 4;
if(s[i] == 'O')x = 2;
if(s[i] == 'I')x = 1;
for(int j = 1;j < 8;j++){
if(!(j & x)){
dp[i][j] = 0;
}
if(dp[i][j] > 10007)dp[i][j] %= 10007;
if(dp[i][j] != 0){
for(int l = 1;l < 8;l++){
if(j & l){
dp[i+1][l] += dp[i][j];
}
}
}
}
}
int ans = 0;
for(int j = 1;j < 8;j++){
ans+=dp[n-1][j];
ans %= 10007;
}
cout <<ans<<endl;
}

ステータス

項目 データ
問題 0006 - 部活のスケジュール表 (Schedule)
ユーザー名 ei2332
投稿日時 2023-11-14 15:01:18
言語 C++17
状態 Accepted
得点 100
ソースコード長 950 Byte
最大実行時間 26 ms
最大メモリ使用量 600 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 26 ms 476 KB
1
2
3
4
5
2014-yo-t4-in2.txt AC 19 ms 448 KB
2
3
4
5
2014-yo-t4-in3.txt AC 16 ms 420 KB
3
4
5
2014-yo-t4-in4.txt AC 22 ms 600 KB
4
5
2014-yo-t4-in5.txt AC 21 ms 592 KB
5