結果
問題 | No.1382 Travel in Mitaru city |
ユーザー |
|
提出日時 | 2021-02-17 18:06:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 233 ms / 2,000 ms |
コード長 | 856 bytes |
コンパイル時間 | 2,820 ms |
コンパイル使用メモリ | 206,508 KB |
最終ジャッジ日時 | 2025-01-18 21:51:00 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 68 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define REP(i,n) for(int i=0; i<(int)(n); i++)int main() {ios_base::sync_with_stdio(0);cin.tie(0);int n, m, s, t;cin >> n >> m >> s >> t;--s, --t;vector<int> p(n);for (int i = 0; i < n; i++)cin >> p[i];vector<vector<int> > edges(n);for (int i = 0; i < m; i++) {int a, b;cin >> a >> b;--a, --b;edges[a].emplace_back(b);edges[b].emplace_back(a);}int cur = p[s];int ret = 0;set<int> x;set<pair<int, int> > y;y.emplace(p[s], s);while (y.size()) {auto itr = y.end();int v = (--itr)->second;x.insert(v);y.erase(itr);if (cur > p[v]) {cur = p[v];++ret;}for (int w: edges[v]) {if (!x.count(w))y.emplace(p[w], w);}}cout << ret << endl;return 0;}