結果
| 問題 |
No.663 セルオートマトンの逆操作
|
| コンテスト | |
| ユーザー |
yuliicppy
|
| 提出日時 | 2019-04-25 09:55:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,999 bytes |
| コンパイル時間 | 675 ms |
| コンパイル使用メモリ | 80,328 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-17 19:27:39 |
| 合計ジャッジ時間 | 1,690 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 WA * 4 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
using namespace std;
#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
#define dump(x) cerr << #x << " = " << (x) << endl;
#else
#define dump(x) ; //何もしない文
#endif
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
//#define int long long
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
template <typename T>
std::string printVector(const std::vector<T> &data)
{
std::stringstream ss;
std::ostream_iterator<T> out_it(ss, ", ");
ss << "[";
std::copy(data.begin(), data.end() - 1, out_it);
ss << data.back() << "]";
return ss.str();
}
const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
LL dp[2020][2][2];
int e[2020];
int N;
int f(int a, int b, int c)
{
if(a == 1 && b == 1 && c == 1) return 0;
if(b == 0 && c == 0) return 0;
return 1;
}
LL solve(int v0, int v1)
{
REP(i,2020) REP(j,2) REP(k,2) dp[i][j][k] = 0;
dp[2][v0][v1] = 1;
FOR(i,2,N) FOR(a,0,2) FOR(b,0,2) FOR(c,0,2)
{
if(f(a,b,c) == e[i-1])
{
dp[i+1][b][c] += dp[i][a][b];
}
}
LL ans = 0;
FOR(a,0,2) FOR(b,0,2)
{
if(f(a,b,v0) == e[N-1] && f(b,v0,v1) == e[0]) ans += dp[N][a][b];
}
return ans;
}
signed main(int argc, char const *argv[])
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
REP(i,N) cin >> e[i];
LL ans = 0;
FOR(v0,0,2) FOR(v1,0,2) ans += solve(v0,v1);
cout << ans % MOD << endl;
}
yuliicppy