結果
| 問題 |
No.220 世界のなんとか2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-13 18:19:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 2,472 bytes |
| コンパイル時間 | 775 ms |
| コンパイル使用メモリ | 91,840 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 01:14:06 |
| 合計ジャッジ時間 | 1,480 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
ll bit(int i) { return 1ll << i; }
const int dy[] = { -1, 1, 0, 0 };
const int dx[] = { 0, 0, 1, -1 };
bool is_on_field(int y, int x, int h, int w) { return 0 <= y and y < h and 0 <= x and x < w; }
int main() {
int p; cin >> p;
vector<vector<vector<ll> > > dp = vectors(p+1, 2, 3, ll());
dp[0][0][0] = 1;
repeat (i,p) {
dp[i+1][1][0] =
+ dp[i][1][0] * 4 /* 0, 3, 6, 9 */
+ dp[i][1][1] * 3 /* 2, 5, 8 */
+ dp[i][1][2] * 3 /* 1, 4, 7 */
+ dp[i][0][0]; /* 3 */
dp[i+1][1][1] =
+ dp[i][1][0] * 3 /* 1, 4, 7 */
+ dp[i][1][1] * 4 /* 0, 3, 6, 9 */
+ dp[i][1][2] * 3 /* 2, 5, 8 */
+ dp[i][0][1]; /* 3 */
dp[i+1][1][2] =
+ dp[i][1][0] * 3
+ dp[i][1][1] * 3
+ dp[i][1][2] * 4
+ dp[i][0][2]; /* 3 */
dp[i+1][0][0] =
+ dp[i][0][0] * 3 /* 0, 6, 9 */
+ dp[i][0][1] * 3
+ dp[i][0][2] * 3;
dp[i+1][0][1] =
+ dp[i][0][0] * 3 /* 0, 6, 9 */
+ dp[i][0][1] * 3
+ dp[i][0][2] * 3;
dp[i+1][0][2] =
+ dp[i][0][0] * 3 /* 0, 6, 9 */
+ dp[i][0][1] * 3
+ dp[i][0][2] * 3;
}
ll ans =
+ dp[p][1][0]
+ dp[p][1][1]
+ dp[p][1][2]
+ dp[p][0][0] - 1;
cout << ans << endl;
return 0;
}