結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | soraie_ |
提出日時 | 2020-11-02 20:40:40 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 308 ms / 2,000 ms |
コード長 | 5,719 bytes |
コンパイル時間 | 2,024 ms |
コンパイル使用メモリ | 189,224 KB |
実行使用メモリ | 30,848 KB |
最終ジャッジ日時 | 2024-07-22 08:00:18 |
合計ジャッジ時間 | 9,134 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 123 ms
16,784 KB |
testcase_03 | AC | 158 ms
30,848 KB |
testcase_04 | AC | 156 ms
30,464 KB |
testcase_05 | AC | 114 ms
30,540 KB |
testcase_06 | AC | 112 ms
30,460 KB |
testcase_07 | AC | 31 ms
9,856 KB |
testcase_08 | AC | 111 ms
27,904 KB |
testcase_09 | AC | 12 ms
5,504 KB |
testcase_10 | AC | 50 ms
14,336 KB |
testcase_11 | AC | 36 ms
11,136 KB |
testcase_12 | AC | 28 ms
10,880 KB |
testcase_13 | AC | 137 ms
20,736 KB |
testcase_14 | AC | 157 ms
23,884 KB |
testcase_15 | AC | 184 ms
26,044 KB |
testcase_16 | AC | 84 ms
16,804 KB |
testcase_17 | AC | 191 ms
28,040 KB |
testcase_18 | AC | 55 ms
13,304 KB |
testcase_19 | AC | 180 ms
26,420 KB |
testcase_20 | AC | 42 ms
9,540 KB |
testcase_21 | AC | 70 ms
16,212 KB |
testcase_22 | AC | 168 ms
25,040 KB |
testcase_23 | AC | 3 ms
5,376 KB |
testcase_24 | AC | 4 ms
5,376 KB |
testcase_25 | AC | 24 ms
10,496 KB |
testcase_26 | AC | 92 ms
17,424 KB |
testcase_27 | AC | 95 ms
17,352 KB |
testcase_28 | AC | 174 ms
26,732 KB |
testcase_29 | AC | 17 ms
7,808 KB |
testcase_30 | AC | 178 ms
29,352 KB |
testcase_31 | AC | 120 ms
22,372 KB |
testcase_32 | AC | 74 ms
14,956 KB |
testcase_33 | AC | 181 ms
29,272 KB |
testcase_34 | AC | 59 ms
13,096 KB |
testcase_35 | AC | 185 ms
28,992 KB |
testcase_36 | AC | 3 ms
5,376 KB |
testcase_37 | AC | 3 ms
5,376 KB |
testcase_38 | AC | 3 ms
5,376 KB |
testcase_39 | AC | 4 ms
5,376 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 308 ms
29,440 KB |
testcase_42 | AC | 65 ms
11,648 KB |
testcase_43 | AC | 123 ms
17,280 KB |
testcase_44 | AC | 35 ms
8,448 KB |
testcase_45 | AC | 128 ms
16,768 KB |
testcase_46 | AC | 2 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; /*----------------------------------ここからマクロ----------------------------------*/ #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define vecin(a) rep(i,a.size())cin >> a[i] #define overload4(_1,_2,_3,_4,name,...) name /*#define rep1(n) for(int i=0;i<(int)n;++i) #define rep2(i,n) for(int i=0;i<(int)n;++i) #define rep3(i,a,b) for(int i=(int)a;i<(int)b;++i) #define rep4(i,a,b,c) for(int i=(int)a;i<(int)b;i+=(int)c)*/ #define rep1(n) for(ll i=0;i<(ll)n;++i) #define rep2(i,n) for(ll i=0;i<(ll)n;++i) #define rep3(i,a,b) for(ll i=(ll)a;i<(ll)b;++i) #define rep4(i,a,b,c) for(ll i=(ll)a;i<(ll)b;i+=(ll)c) #define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__) #ifdef _DEBUG #define debug1(a) cerr << #a << ": " << a << "\n" #define debug2(a,b) cerr << #a << ": " << a << ", " << #b << ": " << b << "\n" #define debug3(a,b,c) cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " << c << "\n" #define debug4(a,b,c,d) cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " << c << ", " << #d << ": " << d << "\n" #define debug(...) overload4(__VA_ARGS__,debug4,debug3,debug2,debug1)(__VA_ARGS__) #define vecout(a) cerr << #a << ": [";rep(i,a.size()){cerr << a[i];cerr << (i == a.size() - 1 ? "":",");}cerr << "]\n" #else #define debug(...) #define vecout(a) #endif #define mp make_pair #define fi first #define se second //struct doset{doset(int n){cout << fixed << setprecision(n);cerr << fixed << setprecision(n);}}; //struct myset{myset(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}; void myset(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);} void doset(int n){cout << fixed << setprecision(n);cerr << fixed << setprecision(n);} void koko(){cerr << "koko\n";} using ll = long long; using ld = long double; using dou = double; const int inf = 1 << 30; const ll INF = 1LL << 61; const ld pi = 3.14159265358; const ll mod1 = 1000000007LL; const ll mod2 = 998244353LL; typedef pair<ll,ll> P; template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; } template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; } //nのm乗をMODで割ったあまりO(logm) ll modpow(ll n,ll m,ll MOD){ if(m == 0)return 1; if(m < 0)return 0; ll res = 1; n %= MOD; while(m){ if(m & 1)res = (res * n) % MOD; m >>= 1; n *= n; n %= MOD; } return res; } ll mypow(ll n,ll m){ if(m == 0)return 1; if(m < 0)return -1; ll res = 1; while(m){ if(m & 1)res = (res * n); m >>= 1; n *= n; } return res; } //素数判定O(sqrt(N)) template<class T> inline bool isp(T n){ bool res = true; if(n == 1 || n == 0)return false; else{ for(ll i = 2;i * i <= n;i++){ if(n % i == 0){ res = false; break; } } return res; } } inline bool Yes(bool b = 1){cout << (b ? "Yes\n":"No\n");return b;} inline bool YES(bool b = 1){cout << (b ? "YES\n":"NO\n");return b;} map<ll,ll> primefactor(ll n){ map<ll,ll> ma; if(n <= 1)return ma; ll m = n; for(ll i = 2;i * i <= n;i++){ while(m % i == 0){ ma[i]++; m /= i; } } if(m != 1)ma[m]++; return ma; } ll __lcm(ll a,ll b){ return a / __gcd(a,b) * b; } inline void in(){return;} template<class First,class...Other>inline void in(First& F,Other&...O){cin >> F;in(O...);} template<ll MOD = mod1> struct fac_solver{ private: ll cmax; vector<ll> fac,finv,inv; public: fac_solver(ll n = 100000):cmax(n),fac(n),finv(n),inv(n){ fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < cmax; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } //二項係数計算nCk ll COM(ll n, ll k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll PER(ll n,ll k){ if(n < k || n < 0 || k < 0)return 0; return fac[n] * finv[n - k] % MOD; } ll stair_pow(ll n){return fac[n];} }; /*----------------------------------マクロここまで----------------------------------*/ int main(){ myset(); doset(10); int N,M; cin >> N >> M; int S,T; cin >> S >> T; S--;T--; vector<int> x(N),y(N); rep(i,N)cin >> x[i] >> y[i]; struct edge{int to;ld cost;}; vector<vector<edge>> es(N); int a,b; rep(i,M){ cin >> a >> b; a--;b--; es[a].push_back({b,sqrtl(abs(x[a] - x[b]) * abs(x[a] - x[b]) + abs(y[a] - y[b]) * abs(y[a] - y[b]))}); es[b].push_back({a,sqrtl(abs(x[a] - x[b]) * abs(x[a] - x[b]) + abs(y[a] - y[b]) * abs(y[a] - y[b]))}); //cout << a << "<->" << b << ":" << es[a].back().cost << "\n"; } typedef pair<ld,int> pii; priority_queue<pii,vector<pii>,greater<pii>> que; vector<ld> dist(N,INF); dist[S] = 0; que.push({0,S}); while(!que.empty()){ pii p = que.top(); que.pop(); //koko(); //debug(p.first,p.second); for(auto x : es[p.second]){ //debug(x.to,x.cost); if(chmin(dist[x.to],dist[p.second] + x.cost)){ que.push({dist[x.to],x.to}); } } } cout << dist[T] << "\n"; vecout(dist); }