結果

問題 No.533 Mysterious Stairs
ユーザー EtoNagisaEtoNagisa
提出日時 2017-06-23 23:30:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 145 ms / 5,000 ms
コード長 1,462 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 162,912 KB
実行使用メモリ 99,480 KB
最終ジャッジ日時 2024-04-15 01:08:02
合計ジャッジ時間 2,589 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 18 ms
13,952 KB
testcase_21 AC 17 ms
14,976 KB
testcase_22 AC 58 ms
39,972 KB
testcase_23 AC 144 ms
98,424 KB
testcase_24 AC 145 ms
99,480 KB
testcase_25 AC 18 ms
13,952 KB
testcase_26 AC 125 ms
86,104 KB
testcase_27 AC 38 ms
27,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int n;
int dfs(vvl &dp, int i,int p) {
	if (i == 0)return dp[i][p]=1;
	if (dp[i][p] != -1)return dp[i][p];
	dp[i][p] = 0;
	REP(j, 3) {
		if (j != p&&i>=j+1) {
			dp[i][p] += dfs(dp, i - j - 1, j);
			dp[i][p] %= MOD;
		}
	}
	return dp[i][p];
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;
	vvl dp(n+1,vl(3,-1));
	REP(i, 3)dfs(dp, n, i);
	cout << (((dp[n][0]+dp[n][1])%MOD+dp[n][2])%MOD*(MOD+1)/2)%MOD << endl;
}
0