結果
問題 |
No.1382 Travel in Mitaru city
|
ユーザー |
![]() |
提出日時 | 2023-01-03 10:36:38 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,299 bytes |
コンパイル時間 | 3,959 ms |
コンパイル使用メモリ | 142,468 KB |
実行使用メモリ | 11,104 KB |
最終ジャッジ日時 | 2024-11-27 01:46:27 |
合計ジャッジ時間 | 12,470 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 52 |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <climits> #include <map> #include <queue> #include <set> #include <cstring> #include <vector> using namespace std; typedef long long ll; struct Node { int v; int X; int Y; Node(int v = -1, int X = -1, int Y = -1) { this->v = v; this->X = X; this->Y = Y; } bool operator>(const Node &n) const { return X < n.X; } }; int main() { int N, M, S, T; cin >> N >> M >> S >> T; int P[N]; for (int i = 0; i < N; ++i) { cin >> P[i]; } vector<int> E[N + 1]; for (int i = 0; i < M; ++i) { int a, b; cin >> a >> b; E[a].push_back(b); E[b].push_back(a); } priority_queue <Node, vector<Node>, greater<Node>> pque; pque.push(Node(S, P[S - 1], 0)); bool visited[N + 1]; memset(visited, false, sizeof(visited)); int ans = 0; while (not pque.empty()) { Node node = pque.top(); pque.pop(); if (visited[node.v]) continue; visited[node.v] = true; ans = max(ans, node.Y); for (int u : E[node.v]) { int p = P[u - 1]; Node next(u, node.X, node.Y); if (node.X > p) { next.X = p; next.Y += 1; } pque.push(next); } } cout << ans << endl; return 0; }