結果
問題 | No.2805 Go to School |
ユーザー | ぷら |
提出日時 | 2024-07-12 22:43:57 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,481 bytes |
コンパイル時間 | 1,830 ms |
コンパイル使用メモリ | 150,572 KB |
実行使用メモリ | 17,916 KB |
最終ジャッジ日時 | 2024-07-12 22:44:04 |
合計ジャッジ時間 | 6,685 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 101 ms
9,216 KB |
testcase_05 | AC | 58 ms
6,940 KB |
testcase_06 | AC | 47 ms
6,944 KB |
testcase_07 | AC | 78 ms
9,156 KB |
testcase_08 | AC | 57 ms
6,944 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | WA | - |
testcase_17 | AC | 87 ms
8,168 KB |
testcase_18 | AC | 60 ms
7,296 KB |
testcase_19 | AC | 138 ms
10,720 KB |
testcase_20 | AC | 228 ms
17,140 KB |
testcase_21 | AC | 106 ms
9,344 KB |
testcase_22 | AC | 136 ms
10,648 KB |
testcase_23 | AC | 134 ms
10,384 KB |
testcase_24 | AC | 41 ms
7,540 KB |
testcase_25 | AC | 160 ms
17,916 KB |
testcase_26 | AC | 86 ms
13,620 KB |
testcase_27 | AC | 8 ms
6,940 KB |
testcase_28 | AC | 14 ms
6,944 KB |
testcase_29 | AC | 45 ms
10,456 KB |
testcase_30 | AC | 69 ms
8,320 KB |
testcase_31 | AC | 116 ms
13,444 KB |
testcase_32 | AC | 166 ms
14,708 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 66 ms
7,808 KB |
testcase_36 | AC | 82 ms
9,216 KB |
testcase_37 | WA | - |
ソースコード
#include <string.h> #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template <typename T> using vc = vector<T>; template <typename T> using vvc = vector<vector<T>>; template <typename T> using vvvc = vector<vector<vector<T>>>; template<class T> using pq = priority_queue<T,vector<T>,greater<T>>; template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); } template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); } int dx4[] = {1,0,-1,0}; int dy4[] = {0,1,0,-1}; #define overload5(a, b, c, d, e, name, ...) name #define overload4(a, b, c, d, name, ...) name #define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf) #define REP1(i, n) for(ll i = 0; i < (n); ++i) #define REP2(i, a, b) for(ll i = (a); i < (b); ++i) #define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c)) #define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__) #define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf) #define per1(i, n) for(ll i = (n)-1; i >= 0; --i) #define per2(i, a, b) for(ll i = (a)-1; i >= b; --i) #define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c)) #define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__) #define setbits(j, n) for(ll iiiii = (n), j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii)) #define perm(v) for(bool permrepflag = true; (permrepflag ? exchange(permrepflag, false) : next_permutation(all(v)));) #define fi first #define se second #define pb push_back #define ppb pop_back #define ppf pop_front #define drop(s) cout << #s << endl, exit(0) #define si(c) (int)(c).size() #define lb(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{})) #define ub(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{})) #define rng(v, l, r) v.begin() + (l), v.begin() + (r) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define SORT(v) sort(all(v)) #define REV(v) reverse(all(v)) #define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end()) #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define overload2(_1, _2, name, ...) name #define vec(type, name, ...) vector<type> name(__VA_ARGS__) #define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) ll inf = 1001001001001001001; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n,m,l,s,e; cin >> n >> m >> l >> s >> e; vvc<pii>road(n); rep(i,m) { int a,b,t; cin >> a >> b >> t; a--; b--; road[a].pb({b,t}); road[b].pb({a,t}); } vc<int>T(l); rep(i,l) { cin >> T[i]; T[i]--; } vc<ll>dist(n,inf); dist[0] = 0; pq<pair<ll,int>>que; que.push({0,0}); while(!que.empty()) { pair<ll,int>now = que.top(); que.pop(); if(dist[now.se] != now.fi) continue; for(auto i:road[now.se]) { if(chmin(dist[i.fi],now.fi+i.se)) { que.push({dist[i.fi],i.fi}); } } } if(dist[n-1] == inf) { cout << -1 << "\n"; return 0; } vc<ll>dist2(n,inf); dist2[n-1] = 0; que.push({0,n-1}); while(!que.empty()) { pair<ll,int>now = que.top(); que.pop(); if(dist2[now.se] != now.fi) continue; for(auto i:road[now.se]) { if(chmin(dist2[i.fi],now.fi+i.se)) { que.push({dist2[i.fi],i.fi}); } } } ll ans = inf; rep(i,l) { if(dist[T[i]] < s+e) { chmin(ans,dist[T[i]]+max(0ll,s-dist[T[i]])+1+dist2[T[i]]); } } cout << ans << "\n"; }