結果

問題 No.1 道のショートカット
ユーザー h_nosonh_noson
提出日時 2016-05-07 20:11:46
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,298 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 60,864 KB
最終ジャッジ日時 2024-04-27 02:20:25
合計ジャッジ時間 695 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:12: error: ‘make_tuple’ was not declared in this scope
   30 |     q.push(make_tuple(0,1,0));
      |            ^~~~~~~~~~
main.cpp:5:1: note: ‘std::make_tuple’ is defined in header ‘<tuple>’; did you forget to ‘#include <tuple>’?
    4 | #include <queue>
  +++ |+#include <tuple>
    5 | using namespace std;
main.cpp:32:26: error: no matching function for call to ‘get<1>(const value_type&)’
   32 |         int from = get<1>(q.top());
      |                    ~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/algorithm:60,
                 from main.cpp:3:
/usr/include/c++/11/utility:223:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)’
  223 |     get(pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/11/utility:223:5: note:   template argument deduction/substitution failed:
main.cpp:32:26: note:   types ‘std::pair<_Tp1, _Tp2>’ and ‘const value_type’ {aka ‘const std::tuple<int, int, int>’} have incompatible cv-qualifiers
   32 |         int from = get<1>(q.top());
      |                    ~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/algorithm:60,
                 from main.cpp:3:
/usr/include/c++/11/utility:228:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)’
  228 |     get(pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/11/utility:228:5: note:   template argument deduction/substitution failed:
main.cpp:32:26: note:   types ‘std::pair<_Tp1, _Tp2>’ and ‘const value_type’ {aka ‘const std::tuple<int, int, int>’} have incompatible cv-qualifiers
   32 |         int from = get<1>(q.top());
      |                    ~~~~~~^~~~~~~~~
In file

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,(int)(n)-1,0)
#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP(i,0,(int)(n)-1)
#define INF 100000000

typedef long long ll;

vector<int> e[50];
int dist[301][51];
int S[1500], T[1500], Y[1500], M[1500];

int main() {
    int i, j, N, C, V;
    priority_queue<tuple<int,int,int>> q; // (-time,to,cost)
    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) e[S[i]].push_back(i);
    rep (i,C+1) rep (j,N+1) dist[i][j] = INF;
    dist[0][1] = 0;
    q.push(make_tuple(0,1,0));
    while (!q.empty()) {
        int from = get<1>(q.top());
        int cost = get<2>(q.top());
        q.pop();
        for (auto x : e[from]) {
            int d = dist[cost][from] + M[x];
            int c = cost + Y[x];
            if (c <= C && dist[c][T[x]] > d) {
                dist[c][T[x]] = d;
                q.push(make_tuple(-d,T[x],c));
            }
        }
    }
    int ans = INF;
    rep (i,C+1) ans = min(ans,dist[i][N]);
    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}
0