結果

問題 No.2805 Go to School
ユーザー aogera
提出日時 2024-08-30 20:50:15
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,842 bytes
コンパイル時間 4,965 ms
コンパイル使用メモリ 329,608 KB
最終ジャッジ日時 2025-04-09 15:43:00
合計ジャッジ時間 5,946 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from main.cpp:4:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::_Vector_base<long long int, std::allocator<long long int> >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = long long int]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <atcoder/all>
using ull = unsigned long long;
using namespace std;
using namespace atcoder;
using vst = vector<string>;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vP = vector<P>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repp(i,k,n) for (ll i = k; i < n; i++)
#define per(i,s,e) for(ll i = s; i >= e; i--)
#define all(v) v.begin(),v.end()
#define yesno(a) a ? cout << "Yes" << '\n' : cout << "No" << '\n'
#define YESNO(a) a ? cout << "YES" << '\n' : cout << "NO" << '\n'
#define UNOmap unordered_map
#define UNOset unordered_set
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define debug(x) cerr << #x << " = " << x << '\n'

template<class... T>void in(T&... a){(cin >> ... >> a);}
template<class T, class... Ts>void out(const T& a, const Ts&... b){cout << a;((cout << ' ' <<  b), ...);cout << '\n';}
template<class T> void vin2(vector<T> &u,vector<T> &v){for(ll i = 0; i < (ll)v.size(); i++) in(u[i],v[i]);}
template<class T> void vin(vector<T> &v){for(ll i = 0; i < (ll)v.size(); i++)in(v[i]);}
template<class T> void vout(vector<T> &v){for(ll i = 0; i < (ll)v.size(); i++) cout << v[i] << ' ';cout << "\n";}

ll INF = 1152921504606846976;ll MOD =998244353; ll MOD1 =1000000007;
/* INF = 1LL << 60 */

#define sl(...) ll __VA_ARGS__; in(__VA_ARGS__)
 
using mint = modint998244353;
using mint1 = modint1000000007;
using mintn = modint;
using vm = vector<mint>;
using vvm = vector<vm>;

vl dx = {0,0,1,-1}, dy = {1,-1,0,0};
//----------------------------------------------



int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);cout<<fixed<<setprecision(15);
//==============================================

  ll N,M,L,S,E;
  in(N,M,L,S,E);
  
  vector<vector<P>> G(N);
  rep(i,M){
    ll a,b,t;
    in(a,b,t);
    a--;b--;
    G[a].push_back(pair(t,b));
    G[b].push_back(pair(t,a));
  }
  
  vl T(L);
  vin(T);
  
  ll ans = INF;
  
  
  auto dijkstra = [&](ll start){
    vl dist(N,INF);
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push({0,start});
    dist[start] = 0;
    while(pq.size()){
      auto[cost,v] = pq.top();
      pq.pop();
      
      if(cost != dist[v]) continue;
      
      for(auto [nc,nv] : G[v]){
        if(dist[v] + nc < dist[nv]){
          dist[nv] = dist[v] + nc;
          pq.push({dist[nv],nv});
        }
      }
    }
    
    return dist;
  };
  
  
  
  vl dist = dijkstra(0);
  vl tg = dijkstra(N-1);
  
  
  rep(i,L){
    ll cur = 0;
    cur += dist[T[i]-1];
    chmax(cur,S);
    if(cur >= S + E) continue;
    cur++;
    cur += tg[T[i]-1];
    chmin(ans,cur);
    
    
  }
    
    if(ans == INF){
      out(-1);
      return 0;
    }
    out(ans);
}
0