提出 #3516953


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<ld> vld;
#define SS(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t){cin >> t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First& first, Rest&...rest){cin >> first;MACRO_VAR_Scan(rest...);}
#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REPI,_REP,)(__VA_ARGS__)
#define ln '\n'

using Weight = ld;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
void add_edge(Graph &g,int a,int b,Weight w=1){g[a].emplace_back(a,b,w);g[b].emplace_back(b,a,w);}
vector<Weight> Dijkstra(const Graph &g,int s) {
    const Weight INF = numeric_limits<Weight>::max()/8;
    using state = tuple<Weight,int>;
    priority_queue<state> q;
    vector<Weight> dist(g.size(),INF);
    dist[s] = 0;
    q.emplace(0,s);
    while (q.size()) {
        Weight d;
        int v;
        tie(d,v) = q.top(); q.pop();
        d *= -1;
        /* if(v == t) return d; */
        if (dist[v]<d) continue;
        for (auto &e : g[v]) {
            if (dist[e.dst] > dist[v] + e.weight) {
                dist[e.dst] = dist[v] + e.weight;
                q.emplace(-dist[e.dst], e.dst);
            }
        }
    }
    return dist;
}

//---------------8<---------------8<---------------8<---------------8<---------------//

int barrier[1010][3];

ld dis(int a, int b) {
  ld res = 0.0;
  res += sqrt(pow(barrier[a][0]-barrier[b][0],2)
            + pow(barrier[a][1]-barrier[b][1],2));
  res -= barrier[a][2] + barrier[b][2];
  if (res < 0) return 0;
  return res;
}

signed main() {

  int start = 0, goal = 1;
  REP(i,2) {
    SS(int,x,y);
    barrier[i][0] = x;
    barrier[i][1] = y;
    barrier[i][2] = 0;
  }

  SS(int,N);
  REP(i,2,N+2) {
    SS(int,x,y,r);
    barrier[i][0] = x;
    barrier[i][1] = y;
    barrier[i][2] = r;
  }

  Graph g(N+2);
  REP(i,N+1) REP(j,i+1,N+2) add_edge(g,i,j,dis(i,j));
  vld v = Dijkstra(g,start);
  cout << setprecision(20) << v[goal] << ln;
}

提出情報

提出日時
問題 E - Cosmic Rays
ユーザ morio__
言語 C++14 (GCC 5.4.1)
得点 600
コード長 2431 Byte
結果 AC
実行時間 189 ms
メモリ 59184 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 3
AC × 49
セット名 テストケース
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt
ケース名 結果 実行時間 メモリ
0_00.txt AC 1 ms 256 KiB
0_01.txt AC 1 ms 256 KiB
0_02.txt AC 1 ms 256 KiB
1_00.txt AC 1 ms 256 KiB
1_01.txt AC 1 ms 256 KiB
1_02.txt AC 53 ms 49016 KiB
1_03.txt AC 53 ms 49656 KiB
1_04.txt AC 49 ms 48892 KiB
1_05.txt AC 54 ms 49656 KiB
1_06.txt AC 49 ms 48128 KiB
1_07.txt AC 48 ms 48384 KiB
1_08.txt AC 53 ms 49656 KiB
1_09.txt AC 52 ms 49276 KiB
1_10.txt AC 49 ms 49152 KiB
1_11.txt AC 51 ms 48764 KiB
1_12.txt AC 50 ms 48636 KiB
1_13.txt AC 48 ms 48768 KiB
1_14.txt AC 54 ms 49980 KiB
1_15.txt AC 56 ms 49980 KiB
1_16.txt AC 53 ms 49408 KiB
1_17.txt AC 54 ms 49656 KiB
1_18.txt AC 53 ms 49400 KiB
1_19.txt AC 55 ms 49980 KiB
1_20.txt AC 48 ms 48896 KiB
1_21.txt AC 49 ms 48576 KiB
1_22.txt AC 55 ms 49656 KiB
1_23.txt AC 53 ms 49656 KiB
1_24.txt AC 55 ms 49980 KiB
1_25.txt AC 52 ms 49020 KiB
1_26.txt AC 55 ms 49528 KiB
1_27.txt AC 52 ms 49020 KiB
1_28.txt AC 54 ms 49784 KiB
1_29.txt AC 53 ms 49784 KiB
1_30.txt AC 48 ms 48640 KiB
1_31.txt AC 49 ms 49024 KiB
1_32.txt AC 52 ms 49408 KiB
1_33.txt AC 53 ms 48636 KiB
1_34.txt AC 46 ms 47872 KiB
1_35.txt AC 48 ms 48896 KiB
1_36.txt AC 47 ms 48640 KiB
1_37.txt AC 47 ms 48384 KiB
1_38.txt AC 189 ms 59184 KiB
1_39.txt AC 188 ms 58672 KiB
1_40.txt AC 185 ms 57708 KiB
1_41.txt AC 188 ms 57520 KiB
1_42.txt AC 53 ms 48576 KiB
1_43.txt AC 54 ms 49980 KiB
1_44.txt AC 52 ms 49784 KiB
1_45.txt AC 56 ms 50804 KiB