結果
問題 | No.1599 Hikyaku |
ユーザー | hirayuu_yc |
提出日時 | 2024-09-20 10:31:56 |
言語 | C++23(gcc13) (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 9,963 bytes |
コンパイル時間 | 4,124 ms |
コンパイル使用メモリ | 290,064 KB |
実行使用メモリ | 110,116 KB |
最終ジャッジ日時 | 2024-09-20 10:32:46 |
合計ジャッジ時間 | 46,191 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 236 ms
93,952 KB |
testcase_01 | AC | 277 ms
100,224 KB |
testcase_02 | AC | 281 ms
100,480 KB |
testcase_03 | AC | 210 ms
93,696 KB |
testcase_04 | AC | 1,214 ms
97,920 KB |
testcase_05 | AC | 472 ms
98,056 KB |
testcase_06 | AC | 1,198 ms
110,116 KB |
testcase_07 | AC | 530 ms
109,844 KB |
testcase_08 | AC | 1,192 ms
109,596 KB |
testcase_09 | AC | 329 ms
98,344 KB |
testcase_10 | AC | 363 ms
95,180 KB |
testcase_11 | AC | 278 ms
94,080 KB |
testcase_12 | AC | 391 ms
96,472 KB |
testcase_13 | AC | 325 ms
96,536 KB |
testcase_14 | AC | 152 ms
93,824 KB |
testcase_15 | AC | 234 ms
93,952 KB |
testcase_16 | AC | 578 ms
93,952 KB |
testcase_17 | WA | - |
testcase_18 | AC | 1,250 ms
98,432 KB |
testcase_19 | AC | 1,398 ms
105,856 KB |
testcase_20 | AC | 1,413 ms
106,960 KB |
testcase_21 | AC | 1,334 ms
99,304 KB |
testcase_22 | AC | 1,341 ms
99,676 KB |
testcase_23 | AC | 1,296 ms
97,308 KB |
testcase_24 | AC | 1,287 ms
97,324 KB |
testcase_25 | AC | 1,352 ms
99,844 KB |
testcase_26 | AC | 1,145 ms
96,744 KB |
testcase_27 | AC | 863 ms
96,452 KB |
testcase_28 | AC | 826 ms
94,920 KB |
testcase_29 | AC | 636 ms
95,140 KB |
testcase_30 | AC | 405 ms
93,960 KB |
testcase_31 | AC | 244 ms
93,696 KB |
testcase_32 | AC | 249 ms
93,824 KB |
testcase_33 | AC | 242 ms
93,952 KB |
testcase_34 | AC | 759 ms
94,044 KB |
testcase_35 | AC | 1,067 ms
94,904 KB |
testcase_36 | AC | 1,244 ms
95,064 KB |
testcase_37 | AC | 1,265 ms
95,064 KB |
testcase_38 | AC | 1,263 ms
95,068 KB |
testcase_39 | AC | 1,252 ms
96,640 KB |
testcase_40 | AC | 1,270 ms
98,596 KB |
testcase_41 | AC | 137 ms
93,824 KB |
testcase_42 | AC | 247 ms
93,824 KB |
testcase_43 | AC | 134 ms
93,824 KB |
testcase_44 | WA | - |
testcase_45 | AC | 619 ms
93,824 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | AC | 243 ms
93,952 KB |
testcase_50 | AC | 427 ms
93,952 KB |
testcase_51 | AC | 621 ms
93,952 KB |
testcase_52 | AC | 414 ms
95,228 KB |
ソースコード
#line 2 "Template/Template.hpp" #include <bits/stdc++.h> using namespace std; #line 8 "Template/InOut.hpp" inline void scan() {} inline void scan(int &a) { std::cin >> a; } inline void scan(unsigned &a) { std::cin >> a; } inline void scan(long &a) { std::cin >> a; } inline void scan(long long &a) { std::cin >> a; } inline void scan(unsigned long long &a) { std::cin >> a; } inline void scan(char &a) { std::cin >> a; } inline void scan(float &a) { std::cin >> a; } inline void scan(double &a) { std::cin >> a; } inline void scan(long double &a) { std::cin >> a; } inline void scan(std::vector<bool> &vec) { for (int32_t i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } } inline void scan(std::string &a) { std::cin >> a; } template <class T> inline void scan(std::vector<T> &vec); template <class T, size_t size> inline void scan(std::array<T, size> &vec); template <class T, class L> inline void scan(std::pair<T, L> &p); template <class T, size_t size> inline void scan(T (&vec)[size]); template <class T> inline void scan(std::vector<T> &vec) { for (auto &i : vec) scan(i); } template <class T> inline void scan(std::deque<T> &vec) { for (auto &i : vec) scan(i); } template <class T, size_t size> inline void scan(std::array<T, size> &vec) { for (auto &i : vec) scan(i); } template <class T, class L> inline void scan(std::pair<T, L> &p) { scan(p.first); scan(p.second); } template <class T, size_t size> inline void scan(T (&vec)[size]) { for (auto &i : vec) scan(i); } template <class T> inline void scan(T &a) { std::cin >> a; } inline void in() {} template <class Head, class... Tail> inline void in(Head &head, Tail &...tail) { scan(head); in(tail...); } inline void print() { std::cout << ' '; } inline void print(const bool &a) { std::cout << a; } inline void print(const int &a) { std::cout << a; } inline void print(const unsigned &a) { std::cout << a; } inline void print(const long &a) { std::cout << a; } inline void print(const long long &a) { std::cout << a; } inline void print(const unsigned long long &a) { std::cout << a; } inline void print(const char &a) { std::cout << a; } inline void print(const char a[]) { std::cout << a; } inline void print(const float &a) { std::cout << a; } inline void print(const double &a) { std::cout << a; } inline void print(const long double &a) { std::cout << a; } inline void print(const std::string &a) { for (auto &&i : a) print(i); } template <class T> inline void print(const std::vector<T> &vec); template <class T, size_t size> inline void print(const std::array<T, size> &vec); template <class T, class L> inline void print(const std::pair<T, L> &p); template <class T, size_t size> inline void print(const T (&vec)[size]); template <class T> inline void print(const std::vector<T> &vec) { if (vec.empty()) return; print(vec[0]); for (auto i = vec.begin(); ++i != vec.end();) { std::cout << ' '; print(*i); } } template <class T> inline void print(const std::deque<T> &vec) { if (vec.empty()) return; print(vec[0]); for (auto i = vec.begin(); ++i != vec.end();) { std::cout << ' '; print(*i); } } template <class T, size_t size> inline void print(const std::array<T, size> &vec) { print(vec[0]); for (auto i = vec.begin(); ++i != vec.end();) { std::cout << ' '; print(*i); } } template <class T, class L> inline void print(const std::pair<T, L> &p) { print(p.first); std::cout << ' '; print(p.second); } template <class T, size_t size> inline void print(const T (&vec)[size]) { print(vec[0]); for (auto i = vec; ++i != end(vec);) { std::cout << ' '; print(*i); } } template <class T> inline void print(const T &a) { std::cout << a; } inline void out() { std::cout << '\n'; } template <class T> inline void out(const T &t) { print(t); std::cout << '\n'; } template <class Head, class... Tail> inline void out(const Head &head, const Tail &...tail) { print(head); std::cout << ' '; out(tail...); } inline void Yes(bool i = true) { out(i ? "Yes" : "No"); } inline void No(bool i = true) { out(i ? "No" : "Yes"); } inline void Takahashi(bool i = true) { out(i ? "Takahashi" : "Aoki"); } inline void Aoki(bool i = true) { out(i ? "Aoki" : "Takahashi"); } inline void First(bool i = true) { out(i ? "First" : "Second"); } inline void Second(bool i = true) { out(i ? "Second" : "First"); } inline void Possible(bool i = true) { out(i ? "Possible" : "Impossible"); } inline void Impossible(bool i = true) { out(i ? "Impossible" : "Possible"); } inline void fls() { std::flush(std::cout); } struct IOsetup { IOsetup() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout << std::fixed << std::setprecision(16); } } iosetup; #line 8 "Template/Util.hpp" using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int; using pll = std::pair<ll, ll>; using pii = std::pair<int, int>; using vl = std::vector<ll>; using vvl = std::vector<std::vector<ll>>; using pdd = std::pair<ld, ld>; using tuplis = std::array<ll, 3>; template <class T> using pq = std::priority_queue<T, std::vector<T>, std::greater<T>>; constexpr ll LINF = (1LL << 62) - (1LL << 31); constexpr int32_t INF = INT_MAX >> 1; constexpr ll MINF = 1LL << 40; constexpr ld DINF = std::numeric_limits<ld>::infinity(); constexpr int32_t MODD = 1000000007; constexpr int32_t MOD = 998244353; constexpr ld EPS = 1e-9; constexpr ld PI = 3.1415926535897932; const ll four[] = {0, 1, 0, -1, 0}; const ll eight[] = {0, 1, 1, 0, -1, -1, 1, -1, 0}; template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } else return false; } template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } else return false; } template <class T> ll sum(const T &a) { return accumulate(std::begin(a), std::end(a), 0LL); } template <class T> ld dsum(const T &a) { return accumulate(std::begin(a), std::end(a), 0.0L); } template <class T> auto min(const T &a) { return *min_element(std::begin(a), std::end(a)); } template <class T> auto max(const T &a) { return *max_element(std::begin(a), std::end(a)); } #line 1 "Template/Macro.hpp" #define _overload3(_1, _2, _3, name, ...) name #define _overload4(_1, _2, _3, _4, name, ...) name #define _rep1(i, n) for (ll i = 0; i < (n); i++) #define _rep2(i, a, b) for (ll i = (a); i < (b); i++) #define _rep3(i, a, b, c) for (ll i = (a); i < (b); i += (c)) #define rep(...) _overload4(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__) #define _rrep1(i, n) for (ll i = (n) - 1; i >= 0; i--) #define _rrep2(i, a, b) for (ll i = (b) - 1; i >= (a); i--) #define rrep(...) _overload3(__VA_ARGS__, _rrep2, _rrep1)(__VA_ARGS__) #define each(i, ...) for (auto&& i : __VA_ARGS__) #define all(i) std::begin(i), std::end(i) #define rall(i) std::rbegin(i), std::rend(i) #define len(x) ((ll)(x).size()) #define fi first #define se second #define uniq(x) x.erase(unique(all(x)), std::end(x)) #define vec(type, name, ...) vector<type> name(__VA_ARGS__); #define vv(type, name, h, ...) std::vector<std::vector<type>> name(h, std::vector<type>(__VA_ARGS__)); #define INT(...) int __VA_ARGS__; in(__VA_ARGS__) #define LL(...) long long __VA_ARGS__; in(__VA_ARGS__) #define ULL(...) unsigned long long __VA_ARGS__; in(__VA_ARGS__) #define STR(...) std::string __VA_ARGS__; in(__VA_ARGS__) #define CHR(...) char __VA_ARGS__; in(__VA_ARGS__) #define LD(...) long double __VA_ARGS__; in(__VA_ARGS__) #define VEC(type, name, size) std::vector<type> name(size); in(name) #define VV(type, name, h, w) std::vector<std::vector<type>> name(h, std::vector<type>(w)); in(name) #line 8 "Template/Template.hpp" constexpr ll H=600,W=600; constexpr ll speed=8; constexpr ld road=1000; int main(){ LL(X,Y); LL(N); VEC(tuplis,mails,N); array<array<array<ld,W>,H>,speed> dist; array<array<array<ld,W>,H>,speed> dp; rep(i,speed){ rep(j,H){ rep(k,W){ dist[i][j][k]=DINF; dp[i][j][k]=DINF; } } } X--;Y--; queue<tuplis> que; rep(i,N){ mails[i][0]--;mails[i][1]--; dist[mails[i][2]][mails[i][0]][mails[i][1]]=0; que.push(mails[i]); } while(!que.empty()){ ll sp=que.front()[2],x=que.front()[0],y=que.front()[1]; que.pop(); rep(i,4){ ll nx=x+four[i],ny=y+four[i+1]; if(nx<0||H<=nx||ny<0||W<=ny)continue; if(isinf(dist[sp][nx][ny])){ dist[sp][nx][ny]=dist[sp][x][y]+road/sp; que.push({nx,ny,sp}); } } } pq<pair<ld,tuplis>> vert; dp[mails[0][2]][mails[0][0]][mails[0][1]]=0; vert.push({0,mails[0]}); while(!vert.empty()){ ll sp=vert.top().se[2],x=vert.top().se[0],y=vert.top().se[1]; ld dis=vert.top().fi; vert.pop(); if(abs(dp[sp][x][y]-dis)>EPS)continue; rep(i,sp+1,speed){ if(chmin(dp[i][x][y],max(dis,dist[i][x][y]))){ vert.push({dp[i][x][y],{x,y,i}}); } } rep(i,4){ ll nx=x+four[i],ny=y+four[i+1]; if(nx<0||H<=nx||ny<0||W<=ny)continue; if(chmin(dp[sp][nx][ny],dis+road/sp)){ vert.push({dp[sp][nx][ny],{nx,ny,sp}}); } rep(j,sp+1,speed){ if(dis+road/sp<dist[j][nx][ny])continue; if(dist[j][nx][ny]+road/j<dis)continue; ld meet=(1000+dis*sp+dist[j][nx][ny]*j)/(sp+j); if(chmin(dp[j][nx][ny],meet*2-dist[j][nx][ny])){ vert.push({dp[j][nx][ny],{nx,ny,j}}); } } } } ld ans=DINF; rep(i,speed){ chmin(ans,dp[i][X][Y]); } out(ans); }