結果
問題 | No.2764 Warp Drive Spacecraft |
ユーザー | Yudai0606Nazo |
提出日時 | 2024-05-20 02:24:21 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,975 bytes |
コンパイル時間 | 5,406 ms |
コンパイル使用メモリ | 286,732 KB |
実行使用メモリ | 30,972 KB |
最終ジャッジ日時 | 2024-05-20 02:24:42 |
合計ジャッジ時間 | 17,140 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | WA | - |
testcase_11 | AC | 1 ms
6,940 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 261 ms
26,824 KB |
testcase_17 | AC | 293 ms
26,816 KB |
testcase_18 | AC | 254 ms
26,656 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 442 ms
30,160 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 452 ms
30,692 KB |
testcase_33 | AC | 242 ms
15,796 KB |
testcase_34 | AC | 222 ms
15,784 KB |
testcase_35 | AC | 225 ms
15,820 KB |
testcase_36 | AC | 224 ms
26,728 KB |
ソースコード
#include <bits/stdc++.h> #include <cassert> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; //using mint = modint1000000007; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repu(i, s, t) for (int i = (int)(s); i < (int)(t); i++) #define repd(i, s, t) for (int i = (int)(s)-1; i >= (int)(t); i--) #define all(v) v.begin(), v.end() template<typename T> bool chmax(T &a, const T b) { if(a >= b) return false; a = b; return true; } template<typename T> bool chmin(T &a, const T b) { if(a <= b) return false; a = b; return true; } template<typename T> istream& operator>>(istream &in, vector<T> &a) { for(T &x: a) in >> x; return in; } template<typename T> ostream& operator<<(ostream &out, const vector<T> &a) { for(const T &x: a) out << x << ' '; return out; } const int di[] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; const int dj[] = {0, 1, 0, -1, -1, 1, 1, -1, 0}; using COST = ll; const COST Z = 0; const COST E = 1; const COST INF = 1e18; struct DIJ { struct EDGE{ int to; COST cost; }; using EList = vector<EDGE>; using GRAPH = vector<EList>; using pci = pair<COST, int>; int n; GRAPH g; vector<vector<COST>> dist; DIJ(int n_): n(n_), g(n_), dist(n_) {} void add_edge(int a, int b, COST c = E) { g[a].push_back(EDGE{b, c}); } vector<COST>& operator[](int i) { if(!dist[i].size()) solve(i); return dist[i]; } void solve(int s) { dist[s].resize(n, INF); priority_queue<pci, vector<pci>, greater<pci>> wait; dist[s][s] = Z; wait.emplace(Z, s); while(!wait.empty()) { int pos; COST cost; tie(cost, pos) = wait.top(); wait.pop(); if(dist[s][pos] < cost) continue; for(auto ed : g[pos]) { COST tmp = cost + ed.cost; if(dist[s][ed.to] <= tmp) continue; dist[s][ed.to] = tmp; wait.emplace(tmp, ed.to); } } } }; int main() { int n, m; cin >> n >> m; vector<int> w(n); cin >> w; DIJ g(n); rep(i, m) { int u, v; ll t; cin >> u >> v >> t; u--; v--; g.add_edge(u, v, t); g.add_edge(v, u, t); } vector<int> ord(n); iota(all(ord), 0); sort(all(ord), [&](int l, int r) { return g[0][l] < g[0][r]; }); map<ll, int> skip; skip[0] = 0; int pre = 0, ls = 0; rep(i, n) { if(w[ord[i]] >= w[ord[pre]]) continue; int tmp = w[ord[pre]] - w[ord[i]]; ll bord = (g[0][ord[i]] - g[0][ord[pre]] + tmp - 1) / tmp; if(bord >= ls) { skip[bord] = i; pre = i; ls = bord; } } ll ans = g[0][n-1]; rep(i, n) { int p = (*--skip.upper_bound(w[i])).second; chmin(ans, g[0][ord[p]] + g[n-1][i] + ll(w[ord[p]]) * w[i]); } cout << ans << endl; return 0; }