結果

問題 No.1 道のショートカット
ユーザー YuZakuroYuZakuro
提出日時 2015-04-24 10:27:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,148 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 71,796 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 12:03:38
合計ジャッジ時間 1,974 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<queue>
#include<vector>
#include<tuple>
#define INF 1000000000
using namespace std;

using T = tuple<int, int, int>;

int N, C, V, s[1500], t[1500], y[1500], m[1500], d[100];
bool done[100];
vector<T> g[100];
int main()
{
  fill(d, d + 100, INF);

  cin >> N >> C >> V;
  for(int i = 0; i < V; i++)
    cin >> s[i];
  for(int i = 0; i < V; i++)
    cin >> t[i];
  for(int i = 0; i < V; i++)
    cin >> y[i];
  for(int i = 0; i < V; i++)
    cin >> m[i];
  for(int i = 0; i < V; i++)
  {
    s[i]--; t[i]--;
    g[s[i]].push_back(make_tuple(m[i], y[i], t[i]));
    g[t[i]].push_back(make_tuple(m[i], y[i], s[i]));
  }

  priority_queue<T, vector<T>, greater<T>> q;
  q.push(make_tuple(0, 0, 0));
  while(q.size())
  {
    auto t = q.top(); q.pop();
    auto n = get<2>(t);
    done[n] = true;
    for(auto e: g[n])
    {
      auto to = get<2>(e);
      auto dist = get<0>(t) + get<0>(e);
      auto cost = get<1>(t) + get<1>(e);
      if(done[to] || d[to] < dist || cost > C)
        continue;
      d[to] = dist;
      q.push(make_tuple(dist, cost, to));
    }
  }
  cout << (d[N - 1] == INF ? -1 : d[N - 1]) << endl;
}
0