結果

問題 No.612 Move on grid
ユーザー ふっぴーふっぴー
提出日時 2017-12-13 11:24:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 183 ms / 2,500 ms
コード長 1,441 bytes
コンパイル時間 1,913 ms
コンパイル使用メモリ 171,692 KB
実行使用メモリ 121,856 KB
最終ジャッジ日時 2024-05-10 03:51:54
合計ジャッジ時間 4,473 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 32 ms
32,000 KB
testcase_04 AC 125 ms
121,728 KB
testcase_05 AC 183 ms
121,728 KB
testcase_06 AC 172 ms
121,856 KB
testcase_07 AC 120 ms
121,728 KB
testcase_08 AC 171 ms
121,728 KB
testcase_09 AC 140 ms
121,728 KB
testcase_10 AC 94 ms
77,312 KB
testcase_11 AC 40 ms
38,656 KB
testcase_12 AC 119 ms
91,520 KB
testcase_13 AC 59 ms
53,120 KB
testcase_14 AC 143 ms
105,856 KB
testcase_15 AC 43 ms
40,704 KB
testcase_16 AC 163 ms
120,320 KB
testcase_17 AC 56 ms
55,168 KB
testcase_18 AC 142 ms
108,032 KB
testcase_19 AC 88 ms
84,352 KB
testcase_20 AC 125 ms
115,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
  int t, i, j;
  cin >> t;
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  vll dp(t + 1, vl(30000));
  dp[0][15000] = 1;
  for (i = 0; i < t; i++) {
    for (j = 0; j < 30000; j++) {
      if (dp[i][j]) {
	dp[i + 1][j + a] += dp[i][j];
	dp[i + 1][j - a] += dp[i][j];
	dp[i + 1][j + b] += dp[i][j];
	dp[i + 1][j - b] += dp[i][j];
	dp[i + 1][j + c] += dp[i][j];
	dp[i + 1][j - c] += dp[i][j];
	dp[i + 1][j + a] %= MOD;
	dp[i + 1][j - a] %= MOD;
	dp[i + 1][j + b] %= MOD;
	dp[i + 1][j - b] %= MOD;
	dp[i + 1][j + c] %= MOD;
	dp[i + 1][j - c] %= MOD;
      }
    }
  }
  ll ans = 0;
  for (i = d + 15000; i <= e + 15000; i++) {
    ans += dp[t][i];
    ans %= MOD;
  }
  cout << ans << endl;
}
0