結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | shimarut |
提出日時 | 2021-04-11 17:59:32 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 390 ms / 2,000 ms |
コード長 | 3,636 bytes |
コンパイル時間 | 3,608 ms |
コンパイル使用メモリ | 196,892 KB |
実行使用メモリ | 24,152 KB |
最終ジャッジ日時 | 2024-06-27 12:40:57 |
合計ジャッジ時間 | 13,533 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 172 ms
13,312 KB |
testcase_03 | AC | 275 ms
24,148 KB |
testcase_04 | AC | 270 ms
24,148 KB |
testcase_05 | AC | 223 ms
24,020 KB |
testcase_06 | AC | 224 ms
24,152 KB |
testcase_07 | AC | 75 ms
8,320 KB |
testcase_08 | AC | 286 ms
21,888 KB |
testcase_09 | AC | 25 ms
5,376 KB |
testcase_10 | AC | 125 ms
11,648 KB |
testcase_11 | AC | 86 ms
8,960 KB |
testcase_12 | AC | 66 ms
9,296 KB |
testcase_13 | AC | 181 ms
15,464 KB |
testcase_14 | AC | 214 ms
16,960 KB |
testcase_15 | AC | 251 ms
20,604 KB |
testcase_16 | AC | 124 ms
12,476 KB |
testcase_17 | AC | 270 ms
19,736 KB |
testcase_18 | AC | 91 ms
10,832 KB |
testcase_19 | AC | 256 ms
19,004 KB |
testcase_20 | AC | 67 ms
7,932 KB |
testcase_21 | AC | 115 ms
12,336 KB |
testcase_22 | AC | 228 ms
17,916 KB |
testcase_23 | AC | 4 ms
5,376 KB |
testcase_24 | AC | 5 ms
5,376 KB |
testcase_25 | AC | 59 ms
8,048 KB |
testcase_26 | AC | 135 ms
13,180 KB |
testcase_27 | AC | 140 ms
13,456 KB |
testcase_28 | AC | 239 ms
20,272 KB |
testcase_29 | AC | 33 ms
6,232 KB |
testcase_30 | AC | 258 ms
21,000 KB |
testcase_31 | AC | 166 ms
15,908 KB |
testcase_32 | AC | 108 ms
11,092 KB |
testcase_33 | AC | 241 ms
20,284 KB |
testcase_34 | AC | 95 ms
10,884 KB |
testcase_35 | AC | 262 ms
19,936 KB |
testcase_36 | AC | 3 ms
5,376 KB |
testcase_37 | AC | 5 ms
5,376 KB |
testcase_38 | AC | 4 ms
5,376 KB |
testcase_39 | AC | 4 ms
5,376 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 390 ms
22,492 KB |
testcase_42 | AC | 102 ms
9,472 KB |
testcase_43 | AC | 182 ms
13,568 KB |
testcase_44 | AC | 62 ms
7,168 KB |
testcase_45 | AC | 178 ms
13,288 KB |
testcase_46 | AC | 2 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
ソースコード
#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; using 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>; //#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 region UnionFind struct 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 GCD ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a%b); } #pragma endregion #pragma region LCM ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } #pragma endregion #pragma region chmin template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } #pragma endregion #pragma region chmax template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } #pragma endregion #pragma region グリッド内チェック 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 endregion #pragma region Dijkstra vl 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 endregion int main() { int n, m, X, Y; cin >> n >> m >> X >> Y; --X, --Y; vector<double> x(n), y(n); rep(i, n)cin >> x[i] >> y[i]; vector<vector<pair<int, double>>> v(n); rep(i, m) { int p, q; cin >> p >> q; --p, --q; double d = sqrt((x[p] - x[q])*(x[p] - x[q]) + (y[p] - y[q])*(y[p] - y[q])); v[p].push_back({ q,d }); v[q].push_back({ p,d }); } ll INF = 1e18; vector<double> dp(n, INF); priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> q; q.push({ 0,X }); while (!q.empty()) { double dist; int now; tie(dist, now) = q.top(); q.pop(); if (!chmin(dp[now], dist))continue; for (auto p : v[now]) { double d; int next; tie(next, d) = p; if (dp[next] > dp[now] + d) { q.push({ dp[now] + d,next }); } } } cout << fixed << setprecision(10) << dp[Y] << endl; }