結果

問題 No.663 セルオートマトンの逆操作
ユーザー kotatsugamekotatsugame
提出日時 2019-10-12 16:37:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 65,504 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 19:55:21
合計ジャッジ時間 2,381 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
long mod=1e9+7,ans;
int T[8]={0,1,1,1,0,1,1,0};
int N,A[2000];
long dp[2020][4];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int x=0;x<4;x++)
	{
		for(int i=0;i<=N;i++)for(int j=0;j<4;j++)dp[i][j]=0;
		dp[0][x]=1;
		for(int i=1;i<N-1;i++)
		{
			for(int j=0;j<4;j++)
			{
				for(int k=0;k<2;k++)
				{
					if(A[i]==T[j*2+k])
					{
						(dp[i][j%2*2+k]+=dp[i-1][j])%=mod;
					}
				}
			}
		}
		for(int j=0;j<4;j++)
		{
			if(A[N-1]==T[j*2+x/2]&&A[0]==T[j%2*4+x])(ans+=dp[N-2][j])%=mod;
		}
	}
	cout<<ans<<endl;
}
0