結果
| 問題 |
No.1382 Travel in Mitaru city
|
| コンテスト | |
| ユーザー |
RheoTommy
|
| 提出日時 | 2021-02-07 20:59:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,543 bytes |
| コンパイル時間 | 2,231 ms |
| コンパイル使用メモリ | 211,884 KB |
| 最終ジャッジ日時 | 2025-01-18 14:05:41 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 TLE * 34 MLE * 5 |
ソースコード
#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);
}
priority_queue<T> pri;
pri.emplace(p[s], s, 0);
vector<ll> dp(n);
set<P> seen;
seen.insert({s, p[s]});
while (!pri.empty()) {
auto[people, now, score] = pri.top();
// cout << people << " " << now << " " << score << endl;
pri.pop();
for (auto next:vertex[now]) {
if (p[next] < people) {
chmax(dp[next], score + 1);
pri.emplace(p[next], next, score + 1);
seen.insert({next, p[next]});
} else if (seen.end() == seen.find({next, people})) {
chmax(dp[next], score);
pri.emplace(people, next, score);
seen.insert({next, people});
}
}
}
cout << dp[t] << endl;
}
RheoTommy