結果

問題 No.1 道のショートカット
ユーザー ojisan_ITojisan_IT
提出日時 2017-08-11 07:02:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,670 bytes
コンパイル時間 1,456 ms
コンパイル使用メモリ 176,536 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-08 04:57:10
合計ジャッジ時間 2,485 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 3 ms
6,944 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 8 ms
6,944 KB
testcase_24 AC 7 ms
6,940 KB
testcase_25 AC 3 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 6 ms
6,940 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 3 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 5 ms
6,940 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 2 ms
6,944 KB
testcase_39 AC 2 ms
6,940 KB
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 1 ms
6,944 KB
testcase_42 AC 1 ms
6,940 KB
testcase_43 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
In function 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]',
    inlined from 'int main()' at main.cpp:64:14:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:235:15: warning: iteration 301 invokes undefined behavior [-Waggressive-loop-optimizations]
  235 |       if (__b < __a)
      |           ~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:63:20: note: within this loop
   63 |   for(int i = 0; i <= 301; i++)
      |                  ~~^~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;

int dp[51][301] ={}; // dp[N][C] = time

struct edge{
  int to,cost,time;
};

vector<edge> G[51];
int s[1500],t[1500],y[1500],m[1500];

int main(){
  int n,c,v; cin >> n>> c >> v;
  rep(i,v)
    cin >> s[i];
  rep(i,v)
    cin >> t[i];
  rep(i,v)
    cin >> y[i];
  rep(i,v)
    cin >> m[i];
  rep(i,v)
    G[s[i]].pb((edge){t[i],y[i],m[i]});
  fill_n(dp[0],51*301,INF);
  priority_queue<pii,vector<pii>,greater<pii > > q; //cost,position
  dp[1][c] = 0;
  q.push(mp(c,1));
  while(!q.empty()){
    int id = q.top().SEC;
    int nowc = q.top().FST;
    q.pop();
    for(int i = 0; i < G[id].size();i++){
      if(nowc-G[id][i].cost>=0 && dp[id][nowc]+G[id][i].time < dp[G[id][i].to][nowc-G[id][i].cost]){
        dp[G[id][i].to][nowc-G[id][i].cost]=dp[id][nowc]+G[id][i].time;
        q.push(mp(nowc-G[id][i].cost,G[id][i].to));
      }
    }
  }
  int ans = INF;
  for(int i = 0; i <= 301; i++)
    ans = min(ans,dp[n][i]);
  cout << ((ans == INF)? -1 : ans) << endl;
}
0