結果

問題 No.1 道のショートカット
ユーザー ojisan_ITojisan_IT
提出日時 2017-08-11 06:31:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,665 bytes
コンパイル時間 1,845 ms
コンパイル使用メモリ 174,820 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-22 13:13:53
合計ジャッジ時間 3,134 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 4 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 8 ms
4,376 KB
testcase_24 AC 9 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 6 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 AC 6 ms
4,384 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/string:50,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/locale_classes.h:40,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/ios_base.h:41,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ios:42,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/istream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/sstream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/complex:45,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ccomplex:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:54,
         次から読み込み:  main.cpp:1:
関数 ‘constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]’ 内,
    inlined from ‘int main()’ at main.cpp:66:14:
/usr/local/gcc7/include/c++/12.2.0/bits/stl_algobase.h:235:15: 警告: iteration 301 invokes undefined behavior [-Waggressive-loop-optimizations]
  235 |       if (__b < __a)
      |           ~~~~^~~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:65:20: 備考: within this loop
   65 |   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 main(){
  int n,c,v; cin >> n>> c >> v;
  vi s(v),t(v),y(v),m(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