// Exported by Exporter.exe // Included from B.cpp // Compile flags -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -fmax-errors=2 #include using namespace std; #define PB push_back #define F first #define S second #define MP make_pair #define MTP make_tuple #define R Read #define RD Read_Digit #define RP Read_P #define RL Read_Loop #define RLD Read_Loop_Digit #define RLP Read_Loop_P typedef long long int ll; typedef unsigned long long int ull; constexpr int kN = int(1E5 + 10); // constexpr int kMod = 998244353; // constexpr int kMod = int(1E9 + 7); constexpr int kInf = 0x3f3f3f3f; // constexpr ll kInf = 0x3f3f3f3f3f3f3f3f; constexpr double kPi = acos(-1); constexpr double kEps = 1E-9; // Included from C:\Users\ianli\Desktop\CP\template\Various\Fast_IO\Fast_IO.cpp // --- Get --- static inline char Get_Raw_Char() { static char buf[1 << 16], *p = buf, *end = buf; if (p == end) { if ((end = buf + fread(buf, 1, 1 << 16, stdin)) == buf) return '\0'; p = buf; } return *p++; } static inline int Get_Digit() { char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); return int(c - '0'); } template static inline int Get_P() { static_assert(is_integral::value); char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); T ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); return ret; } template static inline int Get() { static_assert(is_integral::value); char c = Get_Raw_Char(); bool neg = false; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } T ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); if (neg) return -ret; return ret; } // --- Read --- template static inline void Read_P(T &n) { static_assert(is_integral::value); char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); return ; } template static inline void Read(T &n) { static_assert(is_integral::value); char c = Get_Raw_Char(); bool neg = false; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); if (neg) n = -n; return ; } template static inline void Read_Digit(T &n) { static_assert(is_integral::value); char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); return ; } // --- Read multiple --- template static inline void Read(T &n, Targs&... Fargs) { Read(n); return Read(Fargs...); } template static inline void Read_Digit(T &n, Targs&... Fargs) { Read_Digit(n); return Read_Digit(Fargs...); } template static inline void Read_P(T &n, Targs&... Fargs) { Read_P(n); return Read_P(Fargs...); } // --- Read Loop --- template static inline void Read_Loop_i(int i, T *a) {return Read(a[i]);} template static inline void Read_Loop_i(int i, T *a, Targs*... Fargs) { Read(a[i]); return Read_Loop_i(i, Fargs...); } template static inline void Read_Loop(int n, Targs*... Fargs) { for (int i = 1; i <= n; i++) Read_Loop_i(i, Fargs...); return ; } template static inline void Read_Loop_Digit_i(int i, T *a) {return Read_Digit(a[i]);} template static inline void Read_Loop_Digit_i(int i, T *a, Targs*... Fargs) { Read_Digit(a[i]); return Read_Loop_Digit_i(i, Fargs...); } template static inline void Read_Loop_Digit(int n, Targs*... Fargs) { for (int i = 1; i <= n; i++) Read_Loop_Digit_i(i, Fargs...); return ; } template static inline void Read_Loop_P_i(int i, T *a) {return Read_P(a[i]);} template static inline void Read_Loop_P_i(int i, T *a, Targs*... Fargs) { Read_P(a[i]); return Read_Loop_P_i(i, Fargs...); } template static inline void Read_Loop_P(int n, Targs*... Fargs) { for (int i = 1; i <= n; i++) Read_Loop_P_i(i, Fargs...); return ; } // --- Float --- template static inline void Read(T &n) { char c = Get_Raw_Char(); bool neg = false; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); int cnt = 0; if (c == '.') { while (isdigit(c = Get_Raw_Char())) { n = n * 10 + int(c - '0'); cnt++; } } while (cnt < mul) { n = n * 10; cnt++; } if (neg) n = -n; return ; } template static inline void Read_P(T &n) { char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); int cnt = 0; if (c == '.') { while (isdigit(c = Get_Raw_Char())) { n = n * 10 + int(c - '0'); cnt++; } } while (cnt < mul) { n = n * 10; cnt++; } return ; } template static inline void Read(T &n, Targs&... Fargs) { Read(n); return Read(Fargs...); } template static inline void Read_P(T &n, Targs&... Fargs) { Read_P(n); return Read_P(Fargs...); } // --- cin, cout --- void IOS() { ios::sync_with_stdio(false); cin.tie(0); return ; } // --- freopen --- void Freopen(const char *in, const char *out) { freopen(in, "r", stdin); freopen(out, "w", stdout); return ; } // --- Output __int128 --- template void Print128(T x) { if (x < 0) { printf("-"); x = -x; } if (x == 0) printf("0"); else { static int val[100]; int idx = -1; while (x) { val[++idx] = x % 10; x /= 10; } while (idx >= 0) printf("%d", val[idx--]); } } // End of C:\Users\ianli\Desktop\CP\template\Various\Fast_IO\Fast_IO.cpp // Included from C:\Users\ianli\Desktop\CP\template\Various\Useful_Functions\Useful_Functions.cpp // --- sort --- template inline void sort(vector &v) {return sort(v.begin(), v.end());} template inline void sort(int n, T *a) {return sort(a + 1, a + n + 1);} template inline void sort_r(vector &v) {return sort(v.begin(), v.end(), greater());} template inline void sort_r(int n, T *a) {return sort(a + 1, a + n + 1, greater());} // --- Merge --- template inline void Merge_Vec(vector &a, vector &b, vector &c) { if (c.size() < a.size() + b.size()) c.resize(a.size() + b.size()); merge(a.begin(), a.end(), b.begin(), b.end(), c.begin()); return ; } // --- Discrete --- template inline void Discrete(vector &v) { sort(v); v.resize(unique(v.begin(), v.end()) - v.begin()); return ; } // --- Relabel --- template inline void relabel(int n, T *val, T *dist) { if (!dist) dist = val; T *tmp = new T[n + 1]; memcpy(tmp, val, sizeof(T) * (n + 1)); sort(n, tmp); int sz = unique(tmp + 1, tmp + n + 1) - (tmp + 1); for (int i = 1; i <= n; i++) dist[i] = lower_bound(tmp + 1, tmp + sz + 1, val[i]) - tmp; delete tmp; return ; } // --- PQ --- template using PQ = priority_queue; template using PQ_R = priority_queue, greater>; // --- misc --- template inline T ABS(T n) {return n >= 0 ? n : -n;} template inline T gcd(T a, T b) {return b ? gcd(b, a % b) : a;} template inline T lcm(T a, T b) {return a * b / gcd(a, b);} template inline T mex(T a, T b) {return (a == 0 || b == 0) ? ((a == 1 || b == 1) ? 2 : 1) : 0;} template inline void chmin(T &a, T b) { a = min(a, b); return ; } template inline void chmax(T &a, T b) { a = max(a, b); return ; } // End of C:\Users\ianli\Desktop\CP\template\Various\Useful_Functions\Useful_Functions.cpp // Included from C:\Users\ianli\Desktop\CP\template\Various\Debug\Debug.cpp void print(const int &x) {printf("%d", x);} void print(const long long int &x) {printf("%lld", x);} void print(const double &x) {printf("%.20lf", x);} void print(const char *x) {printf("%s", x);} void print(const int n, const int *x) { printf("%d", x[1]); for (int i = 2; i <= n; i++) printf(" %d", x[i]); printf("\n"); return ; } void print(const int n, const long long int *x) { printf("%lld", x[1]); for (int i = 2; i <= n; i++) printf(" %lld", x[i]); printf("\n"); return ; } // End of C:\Users\ianli\Desktop\CP\template\Various\Debug\Debug.cpp inline int dcmp(double x) {return ABS(x) < kEps ? 0 : (x > 0 ? 1 : -1);} int x[kN], y[kN], r[kN], v[kN], a[kN], w; pair position_time(int idx, double t) { return MP(x[idx] + r[idx] * cos((v[idx] * t + a[idx]) * kPi / 180), y[idx] + r[idx] * sin((v[idx] * t + a[idx]) * kPi / 180)); } double travel_time(pair from, pair to) { double x = from.F - to.F, y = from.S - to.S; return sqrt(x * x + y * y) / w; } pair> eat_sushi(int idx, pair from, double t) { double l = t, r = t + 600; // 400 * sqrt(2) ~= 565 for (int i = 1; i <= 30; i++) { // log2(6E7) != 25.8 double mid = (l + r) / 2; if (travel_time(from, position_time(idx, mid)) + t < mid) r = mid; else l = mid; } return MP(l, position_time(idx, l)); } pair> dp[1 << 12][12]; // dp[mask][lst] = (t, (x, y)) int main() { int n; RP(n, w); RL(n, x, y, r, v, a); int tot = 1 << n; for (int mask = 1; mask < tot; mask++) for (int id = 1; id <= n; id++) dp[mask][id - 1].F = kInf; for (int first = 1; first <= n; first++) dp[1 << (first - 1)][first - 1] = eat_sushi(first, MP(0, 0), 0); for (int mask = 1; mask < tot; mask++) for (int lst = 1; lst <= n; lst++) if (mask & (1 << (lst - 1))) { for (int nxt = 1; nxt <= n; nxt++) if (!(mask & (1 << (nxt - 1)))) chmin(dp[mask | (1 << (nxt - 1))][nxt - 1], eat_sushi(nxt, dp[mask][lst - 1].S, dp[mask][lst - 1].F)); } double ans = kInf; for (int i = 1; i <= n; i++) ans = min(ans, dp[tot - 1][i - 1].F); printf("%.20lf\n", ans); } // End of B.cpp