結果
問題 |
No.1382 Travel in Mitaru city
|
ユーザー |
![]() |
提出日時 | 2021-02-07 22:14:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,382 bytes |
コンパイル時間 | 2,275 ms |
コンパイル使用メモリ | 216,640 KB |
最終ジャッジ日時 | 2025-01-18 14:54:14 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 TLE * 30 MLE * 2 |
ソースコード
#include<bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int) n; i++) using ll = long long; using namespace std; using T = tuple<ll, ll, ll>; using P = pair<ll, ll>; const long long INF = 1ll << 60; template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { ll n, m, s, t; cin >> n >> m >> s >> t; s--; t--; vector<ll> p(n); rep(i, n) cin >> p[i]; vector<vector<ll>> vertex(n); rep(i, m) { ll a, b; cin >> a >> b; a--; b--; vertex[a].push_back(b); vertex[b].push_back(a); } ll ans = 0; priority_queue<T> pri; vector<map<ll, ll>> seen(n); seen[s][0] = p[s]; pri.emplace(p[s], s, 0); while (!pri.empty()) { auto[pi, i, score] = pri.top(); pri.pop(); if (i == t) chmax(ans, score); for (auto j : vertex[i]) { if (p[j] < pi) { pri.emplace(p[j], j, score + 1); seen[j][score + 1] = p[j]; } else if (pi > seen[j][score]) { pri.emplace(pi, j, score); seen[j][score] = pi; } } } cout << ans << endl; }