結果
問題 | No.2805 Go to School |
ユーザー | aogera |
提出日時 | 2024-08-30 20:54:57 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 260 ms / 2,000 ms |
コード長 | 3,167 bytes |
コンパイル時間 | 8,001 ms |
コンパイル使用メモリ | 352,208 KB |
実行使用メモリ | 24,472 KB |
最終ジャッジ日時 | 2024-08-30 20:55:10 |
合計ジャッジ時間 | 12,810 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 78 ms
16,768 KB |
testcase_05 | AC | 94 ms
14,056 KB |
testcase_06 | AC | 54 ms
9,156 KB |
testcase_07 | AC | 45 ms
9,280 KB |
testcase_08 | AC | 76 ms
14,424 KB |
testcase_09 | AC | 56 ms
9,200 KB |
testcase_10 | AC | 46 ms
9,056 KB |
testcase_11 | AC | 260 ms
21,252 KB |
testcase_12 | AC | 139 ms
14,524 KB |
testcase_13 | AC | 201 ms
18,600 KB |
testcase_14 | AC | 25 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 80 ms
11,476 KB |
testcase_19 | AC | 54 ms
8,924 KB |
testcase_20 | AC | 135 ms
15,912 KB |
testcase_21 | AC | 210 ms
20,168 KB |
testcase_22 | AC | 87 ms
10,848 KB |
testcase_23 | AC | 125 ms
14,616 KB |
testcase_24 | AC | 119 ms
14,556 KB |
testcase_25 | AC | 35 ms
8,704 KB |
testcase_26 | AC | 152 ms
24,472 KB |
testcase_27 | AC | 72 ms
16,584 KB |
testcase_28 | AC | 8 ms
6,948 KB |
testcase_29 | AC | 12 ms
7,808 KB |
testcase_30 | AC | 37 ms
12,544 KB |
testcase_31 | AC | 57 ms
10,624 KB |
testcase_32 | AC | 109 ms
18,752 KB |
testcase_33 | AC | 161 ms
19,912 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 62 ms
9,188 KB |
testcase_37 | AC | 60 ms
10,240 KB |
testcase_38 | AC | 128 ms
15,432 KB |
ソースコード
#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; vl tg(N,INF); { priority_queue<P,vector<P>,greater<P>> Q; tg[N-1] = 0; Q.emplace(0,N-1); while(Q.size()){ auto[cost,v] = Q.top(); Q.pop(); if(cost != tg[v]) continue; for(auto [nc,nv] : G[v]){ if(tg[nv] <= cost + nc) continue; tg[nv] = cost+nc; Q.push(pair(cost+nc,nv)); } } } vl dist(N,INF); { priority_queue<P,vector<P>,greater<P>> Q; dist[0] = 0; Q.push(pair(0,0)); while(Q.size()){ auto[cost,v] = Q.top(); Q.pop(); if(cost > dist[v]) continue; for(auto [nc,nv] : G[v]){ if(nc + cost >= dist[nv]) continue; dist[nv] = nc + cost; Q.emplace(nc+cost,nv); } } } 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); }