結果

問題 No.1382 Travel in Mitaru city
ユーザー 👑 emthrmemthrm
提出日時 2021-02-07 21:11:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,881 bytes
コンパイル時間 2,386 ms
コンパイル使用メモリ 215,804 KB
実行使用メモリ 14,320 KB
最終ジャッジ日時 2023-09-17 20:11:51
合計ジャッジ時間 9,116 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 91 ms
10,116 KB
testcase_27 AC 96 ms
10,048 KB
testcase_28 AC 92 ms
10,176 KB
testcase_29 AC 86 ms
9,988 KB
testcase_30 AC 83 ms
9,984 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 41 ms
8,468 KB
testcase_37 AC 8 ms
4,380 KB
testcase_38 AC 45 ms
9,060 KB
testcase_39 AC 13 ms
4,700 KB
testcase_40 AC 34 ms
7,676 KB
testcase_41 AC 38 ms
8,268 KB
testcase_42 AC 45 ms
9,376 KB
testcase_43 AC 39 ms
8,604 KB
testcase_44 AC 17 ms
5,040 KB
testcase_45 AC 36 ms
8,048 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 3 ms
4,380 KB
testcase_62 AC 2 ms
4,380 KB
testcase_63 AC 9 ms
4,376 KB
testcase_64 AC 4 ms
4,380 KB
testcase_65 AC 2 ms
4,376 KB
testcase_66 AC 3 ms
4,376 KB
testcase_67 AC 3 ms
4,376 KB
testcase_68 AC 4 ms
4,376 KB
testcase_69 AC 3 ms
4,380 KB
testcase_70 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, m, s, t; cin >> n >> m >> s >> t; --s; --t;
  vector<int> p(n); REP(i, n) cin >> p[i];
  vector<int> ps = p;
  sort(ALL(ps));
  ps.erase(unique(ALL(ps)), ps.end());
  REP(i, n) p[i] = lower_bound(ALL(ps), p[i]) - ps.begin();
  vector<vector<int>> graph(n);
  while (m--) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  vector<int> y(n, -1);
  y[s] = 0;
  vector<bool> visited(n, false);
  visited[s] = true;
  set<pair<int, int>> que;
  que.emplace(-p[s], s);
  for (int i = p[s]; i >= 0; --i) {
    while (!que.empty() && -que.begin()->first >= i) {
      auto [_, v] = *que.begin();
      que.erase(que.begin());
      visited[v] = true;
      for (int e : graph[v]) {
        if (p[e] < i) {
          chmax(y[e], y[v] + 1);
        } else {
          chmax(y[e], y[v]);
        }
        if (!visited[e]) que.emplace(-p[e], e);
      }
    }
  }
  cout << *max_element(ALL(y)) << '\n';
  return 0;
}
0