結果

問題 No.612 Move on grid
ユーザー kurarrrkurarrr
提出日時 2018-02-23 15:09:46
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 1,103 ms / 2,500 ms
コード長 1,331 bytes
コンパイル時間 1,399 ms
コンパイル使用メモリ 172,216 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-08 04:00:38
合計ジャッジ時間 10,946 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

template<class T> void chmax(T& a,const T& b){a=max(a,b);}
template<class T> void chmin(T& a,const T& b){a=min(a,b);}

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

unordered_map<int,ll> now,nxt;

void update(int f,ll x){
  if(nxt.count(f)){
    (nxt[f] += x) %= lmod;
  }else{
    nxt[f] = x;
  }
}

int main(){
  int T,a,b,c,d,e,f,g;
  cin >> T;
  cin >> a >> b >> c >> d >> e;
  now[0] = 1;
  rep(i,T){
    nxt.clear();
    for(auto u:now){
      tie(f,g) = u;
      update(f+a,g);
      update(f+b,g);
      update(f+c,g);
      update(f-a,g);
      update(f-b,g);
      update(f-c,g);
    }
    swap(now,nxt);
  }
  ll ans = 0LL;
  for(auto u:now){
    tie(f,g) = u;
    if(f>=d && f<=e) (ans += g) %= lmod;
  }
  cout << ans << endl;
  return 0;
}
0