結果
問題 | No.2695 Warp Zone |
ユーザー | addnine |
提出日時 | 2024-03-22 22:42:29 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 835 bytes |
コンパイル時間 | 2,322 ms |
コンパイル使用メモリ | 209,588 KB |
実行使用メモリ | 814,012 KB |
最終ジャッジ日時 | 2024-03-22 22:42:36 |
合計ジャッジ時間 | 6,109 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 2 ms
6,676 KB |
testcase_02 | AC | 2 ms
6,676 KB |
testcase_03 | AC | 576 ms
265,640 KB |
testcase_04 | MLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define all(v) (v).begin(), (v).end() using ll = long long; using ld = long double; using pint = pair<int, int>; using pll = pair<ll, ll>; int main() { int H, W, N; cin >> H >> W >> N; vector<ll> a(N), b(N), c(N), d(N); for (int i = 0; i < N; i++) { cin >> a[i] >> b[i] >> c[i] >> d[i]; a[i]--, b[i]--, c[i]--, d[i]--; } priority_queue<pll, vector<pll>, greater<pll>> que; que.push({0, 0}); ll ans = 2e9 + 7; while(!que.empty()) { auto [dist, pos] = que.top(); que.pop(); ll y = pos/W, x = pos%W; if (dist >= ans) break; ans = min(ans, dist+(H-1-y)+(W-1-x)); for (int i = 0; i < N; i++) { que.push({dist+abs(a[i]-y)+abs(b[i]-x)+1, c[i]*W+d[i]}); } } cout << ans << endl; }