結果
| 問題 | No.663 セルオートマトンの逆操作 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-10-12 16:37:01 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 569 bytes | 
| コンパイル時間 | 537 ms | 
| コンパイル使用メモリ | 65,152 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-28 03:32:20 | 
| 合計ジャッジ時間 | 1,468 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 29 | 
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~
            
            ソースコード
#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;
}
            
            
            
        