結果
問題 | No.1382 Travel in Mitaru city |
ユーザー |
![]() |
提出日時 | 2021-05-03 18:41:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 3,611 bytes |
コンパイル時間 | 3,341 ms |
コンパイル使用メモリ | 189,596 KB |
実行使用メモリ | 10,808 KB |
最終ジャッジ日時 | 2024-07-22 09:28:44 |
合計ジャッジ時間 | 12,154 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 68 |
ソースコード
#pragma region#define _USE_MATH_DEFINES#include <iostream>#include <string>#include <algorithm>#include <cmath>#include <cstdlib>#include <vector>#include <map>#include <queue>#include <stack>#include <set>#include <list>#include <iomanip>#include <cstdint>#include <bitset>#include <sstream>#include <regex>#include <fstream>#include <array>#include <atcoder/all>using namespace atcoder;using mint = modint1000000007;//using mint = modint998244353;//using mint = modint;#pragma region usingusing namespace std;typedef long long ll;using vi = vector<int>;using vvi = vector<vi>;using vl = vector<ll>;using vvl = vector<vl>;using vmint = vector<mint>;using vvmint = vector<vmint>;using pint = pair<int, int>;using pll = pair<ll, ll>;using vpint = vector<pint>;using vvpint = vector<vpint>;using vd = vector<double>;using vvd = vector<vd>;//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))#define all(x) x.begin(),x.end()#define rall(x) x.rbegin(),x.rend()#pragma endregion#pragma region UnionFindstruct UnionFind{vector<int> par;UnionFind(int n) : par(n, -1) {}void init(int n) { par.assign(n, -1); }int root(int x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(int x, int y){return root(x) == root(y);}bool merge(int x, int y){x = root(x); y = root(y);if (x == y) return false;if (par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x){return -par[root(x)];}};#pragma endregion#pragma region GCDll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a%b);}#pragma endregion#pragma region LCMll lcm(ll a, ll b){return a / gcd(a, b) * b;}#pragma endregion#pragma region chmintemplate<class T> inline bool chmin(T& a, T b){if (a > b){a = b;return true;}return false;}#pragma endregion#pragma region chmaxtemplate<class T> inline bool chmax(T& a, T b){if (a < b){a = b;return true;}return false;}#pragma endregion#pragma region Dijkstravl dijkstra(vector<vector<pair<int, ll>>> v, int s){ll INF = 1e18;int MAX = 1e6;vl res(MAX, INF);priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;q.push({ 0,s });while (!q.empty()){int now;ll d;tie(d, now) = q.top();q.pop();if (!chmin(res[now], d))continue;for (auto p : v[now]){int next;ll c;tie(next, c) = p;if (res[next] <= res[now] + c)continue;q.push({ res[now] + c,next });}}return res;}#pragma endregion#pragma region degからraddouble dtor(double deg) { return deg * M_PI / 180; }#pragma endregion#pragma region radからdegdouble rtod(double r) { return r * 180 / M_PI; }#pragma endregion//グリッド内チェックbool out(int x, int y, int h, int w){if (x < 0 || h <= x || y < 0 || w <= y)return true;else return false;}#pragma endregionint main(){int n, m, s, t; cin >> n >> m >> s >> t;--s, --t;vi p(n); rep(i, n)cin >> p[i];vvi v(n);rep(i, m){int a, b; cin >> a >> b;--a, --b;v[a].push_back(b);v[b].push_back(a);}vi seen(n);seen[s] = 1;priority_queue<pint> q;for (int u : v[s]){q.push({ p[u],u });seen[u] = 1;}int x = p[s];int y = 0;while (!q.empty()){int nx, next; tie(nx, next) = q.top();q.pop();if (chmin(x, nx))++y;for (auto u : v[next]){if (seen[u])continue;seen[u] = 1;q.push({ p[u],u });}}cout << y << endl;}