結果
問題 | No.1382 Travel in Mitaru city |
ユーザー |
|
提出日時 | 2022-12-28 18:33:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 922 bytes |
コンパイル時間 | 2,302 ms |
コンパイル使用メモリ | 206,188 KB |
最終ジャッジ日時 | 2025-02-09 21:20:23 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 MLE * 1 |
other | AC * 54 TLE * 12 MLE * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { 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>> G(N); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } priority_queue<pair<int, int>> que; vector<bool> seen(N, false); seen[S] = true; for (auto nv : G[S]) que.emplace(p[nv], nv); int ans = 0; int mini = p[S]; while (!que.empty()) { auto pa = que.top(); que.pop(); int v = pa.second; seen[v] = true; if (pa.first < mini) { mini = pa.first; ans++; } for (auto nv : G[v]) { if (seen[nv]) continue; que.emplace(p[nv], nv); } } cout << ans << endl; }