結果

問題 No.612 Move on grid
ユーザー gzlcpgzlcp
提出日時 2017-12-12 17:10:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 2,500 ms
コード長 1,328 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 96,104 KB
実行使用メモリ 83,344 KB
最終ジャッジ日時 2023-08-22 22:14:43
合計ジャッジ時間 3,514 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 35 ms
22,384 KB
testcase_04 AC 128 ms
83,252 KB
testcase_05 AC 125 ms
83,344 KB
testcase_06 AC 126 ms
83,284 KB
testcase_07 AC 126 ms
83,196 KB
testcase_08 AC 127 ms
83,280 KB
testcase_09 AC 126 ms
83,196 KB
testcase_10 AC 78 ms
53,220 KB
testcase_11 AC 38 ms
26,844 KB
testcase_12 AC 94 ms
62,660 KB
testcase_13 AC 53 ms
36,520 KB
testcase_14 AC 110 ms
72,476 KB
testcase_15 AC 45 ms
28,300 KB
testcase_16 AC 124 ms
82,224 KB
testcase_17 AC 55 ms
38,104 KB
testcase_18 AC 111 ms
74,008 KB
testcase_19 AC 94 ms
57,948 KB
testcase_20 AC 120 ms
78,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll t,a,b,c,d,e;
	cin>>t>>a>>b>>c>>d>>e;
	vector<vector<ll>> dp(t,vector<ll>(20001,0));
	dp[0][10000+a]++; dp[0][10000-a]++;
	dp[0][10000+b]++; dp[0][10000-b]++;
	dp[0][10000+c]++; dp[0][10000-c]++;
	FOR(i,1,t) {
		REP(j,20001) {
			if(j+a<20001&&j+a>=0) dp[i][j]+=dp[i-1][j+a];
			if(j-a<20001&&j-a>=0) dp[i][j]+=dp[i-1][j-a];
			if(j+b<20001&&j+b>=0) dp[i][j]+=dp[i-1][j+b];
			if(j-b<20001&&j-b>=0) dp[i][j]+=dp[i-1][j-b];
			if(j+c<20001&&j+c>=0) dp[i][j]+=dp[i-1][j+c];
			if(j-c<20001&&j-c>=0) dp[i][j]+=dp[i-1][j-c];
			dp[i][j]%=MOD;
		}
	}
	ll ans=0;
	REP(i,20001) if(i>=d+10000&&i<=e+10000) ans+=dp[t-1][i];
	cout<<ans%MOD<<endl;
}
0