結果
問題 | No.1599 Hikyaku |
ユーザー | hirayuu_yc |
提出日時 | 2024-09-20 11:17:40 |
言語 | C++23(gcc13) (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,012 ms / 7,500 ms |
コード長 | 10,288 bytes |
コンパイル時間 | 6,678 ms |
コンパイル使用メモリ | 290,456 KB |
実行使用メモリ | 64,972 KB |
最終ジャッジ日時 | 2024-09-20 11:18:21 |
合計ジャッジ時間 | 35,494 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 176 ms
48,792 KB |
testcase_01 | AC | 224 ms
55,040 KB |
testcase_02 | AC | 220 ms
55,184 KB |
testcase_03 | AC | 125 ms
48,896 KB |
testcase_04 | AC | 903 ms
53,104 KB |
testcase_05 | AC | 322 ms
52,924 KB |
testcase_06 | AC | 848 ms
64,860 KB |
testcase_07 | AC | 361 ms
64,972 KB |
testcase_08 | AC | 855 ms
64,592 KB |
testcase_09 | AC | 190 ms
53,216 KB |
testcase_10 | AC | 234 ms
50,048 KB |
testcase_11 | AC | 177 ms
49,152 KB |
testcase_12 | AC | 292 ms
50,516 KB |
testcase_13 | AC | 239 ms
50,512 KB |
testcase_14 | AC | 97 ms
48,768 KB |
testcase_15 | AC | 181 ms
48,768 KB |
testcase_16 | AC | 443 ms
49,024 KB |
testcase_17 | AC | 950 ms
52,992 KB |
testcase_18 | AC | 916 ms
53,248 KB |
testcase_19 | AC | 998 ms
60,800 KB |
testcase_20 | AC | 1,012 ms
60,544 KB |
testcase_21 | AC | 962 ms
53,412 KB |
testcase_22 | AC | 963 ms
53,652 KB |
testcase_23 | AC | 928 ms
51,284 KB |
testcase_24 | AC | 984 ms
51,556 KB |
testcase_25 | AC | 941 ms
52,708 KB |
testcase_26 | AC | 854 ms
50,688 KB |
testcase_27 | AC | 629 ms
50,524 KB |
testcase_28 | AC | 613 ms
49,644 KB |
testcase_29 | AC | 494 ms
49,612 KB |
testcase_30 | AC | 306 ms
48,960 KB |
testcase_31 | AC | 180 ms
48,896 KB |
testcase_32 | AC | 182 ms
48,768 KB |
testcase_33 | AC | 184 ms
48,640 KB |
testcase_34 | AC | 563 ms
48,976 KB |
testcase_35 | AC | 793 ms
49,488 KB |
testcase_36 | AC | 906 ms
49,392 KB |
testcase_37 | AC | 912 ms
49,392 KB |
testcase_38 | AC | 918 ms
49,524 KB |
testcase_39 | AC | 922 ms
51,016 KB |
testcase_40 | AC | 907 ms
53,340 KB |
testcase_41 | AC | 80 ms
48,768 KB |
testcase_42 | AC | 190 ms
48,768 KB |
testcase_43 | AC | 83 ms
48,896 KB |
testcase_44 | AC | 470 ms
48,896 KB |
testcase_45 | AC | 487 ms
48,896 KB |
testcase_46 | AC | 583 ms
48,896 KB |
testcase_47 | AC | 616 ms
48,768 KB |
testcase_48 | AC | 890 ms
49,024 KB |
testcase_49 | AC | 207 ms
48,768 KB |
testcase_50 | AC | 354 ms
48,768 KB |
testcase_51 | AC | 468 ms
49,024 KB |
testcase_52 | AC | 247 ms
49,872 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 = 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}}); } array<ld,speed> meet; array<ld,speed> rest; fill(all(meet),DINF); meet[sp]=dis; rest[sp]=1000; rep(j,sp+1,speed){ rep(k,sp,j){ if(isinf(meet[k]))continue; if(meet[k]+rest[k]/sp<dist[j][nx][ny])continue; if(dist[j][nx][ny]+rest[k]/j<meet[k])continue; if(chmin(meet[j],(rest[k]+meet[k]*k+dist[j][nx][ny]*j)/(k+j)))rest[j]=(meet[j]-dist[j][nx][ny])*j; } if(chmin(dp[j][nx][ny],meet[j]*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); }