結果
問題 |
No.2695 Warp Zone
|
ユーザー |
![]() |
提出日時 | 2024-03-22 22:42:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 835 bytes |
コンパイル時間 | 2,115 ms |
コンパイル使用メモリ | 200,656 KB |
最終ジャッジ日時 | 2025-02-20 12:14:04 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 4 MLE * 1 -- * 19 |
ソースコード
#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; }