結果

問題 No.1 道のショートカット
ユーザー mayo031042mayo031042
提出日時 2021-04-20 16:26:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,954 bytes
コンパイル時間 1,827 ms
コンパイル使用メモリ 182,604 KB
実行使用メモリ 812,652 KB
最終ジャッジ日時 2023-09-17 08:45:02
合計ジャッジ時間 7,159 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using vi = vector<int>;
using si = set<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
template<typename T> using minpq = priority_queue <T,vector<T>,greater<T>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define P pair<int,int>
#define PLL pair<ll,ll>
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define rev(i,s,n) for(int i=(s);i>=(int)(n);i--)
#define reciv(v,n) vll (v)((n)); rep(i,0,(n))cin>>v[i]
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) ll x;cin >> x
#define cci(x,y) ll x,y;cin >> x >> y
#define co(x) cout << x << endl
#define pb push_back
#define eb emplace_back
#define rz resize
#define pu push
#define sz(x) int(x.size())
#define vij v[i][j]
// ll p = 1e9+7;
// ll p = 998244353;
// n do -> n*pi/180
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl
#define YN cout<<"YES"<<endl;else cout<<"NO"<<endl
template<class T>void chmax(T &x,T y){x=max(x,y);}
template<class T>void chmin(T &x,T y){x=min(x,y);}

struct ed{
  int to,tm,mn;
  ed(int to,int tm,int mn):to(to),tm(tm),mn(mn){}
};

int main(){
  cci(n,c);
  cii(m);
  
  vvi tb(4,vi(m));
  rep(i,0,4){
    rep(j,0,m)ci(tb[i][j]);
  }

  V<V<ed>> v(n);
  rep(i,0,m){
    int fr=tb[0][i]-1;
    int nx=tb[1][i]-1;
    int M=tb[2][i];
    int T=tb[3][i];

    v[fr].eb(nx,T,M);
  }

  V<V<P>> dp(n);
  dp[0].pb(P(0,0));

  queue<int>q;
  q.pu(0);
  while(sz(q)){
    int x=q.front();q.pop();
    int dist,money;

    for(ed e:v[x]){
      for(P np:dp[x]){
        tie(dist,money)=np;

        if(money+e.mn>c)continue;

        dp[e.to].pb(P(dist+e.tm,money+e.mn));
        q.pu(e.to);
      }
    }
  }

  int ans=1001001001;
  for(P np:dp[n-1])chmin(ans,np.first);
  
  if(ans==1001001001)ans=-1;
  co(ans);
}
0