結果
問題 | No.1638 Robot Maze |
ユーザー | kimiyuki |
提出日時 | 2021-08-06 21:35:21 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,999 bytes |
コンパイル時間 | 2,288 ms |
コンパイル使用メモリ | 216,676 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-17 01:26:47 |
合計ジャッジ時間 | 3,713 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 3 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | WA | - |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 3 ms
6,940 KB |
testcase_17 | WA | - |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,944 KB |
testcase_22 | AC | 2 ms
6,944 KB |
testcase_23 | WA | - |
testcase_24 | AC | 3 ms
6,944 KB |
testcase_25 | AC | 2 ms
6,944 KB |
testcase_26 | WA | - |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | WA | - |
testcase_30 | AC | 2 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,944 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 3 ms
6,940 KB |
testcase_35 | AC | 4 ms
6,940 KB |
testcase_36 | WA | - |
testcase_37 | AC | 3 ms
6,944 KB |
testcase_38 | WA | - |
testcase_39 | AC | 3 ms
6,940 KB |
testcase_40 | WA | - |
testcase_41 | AC | 3 ms
6,940 KB |
testcase_42 | AC | 4 ms
6,940 KB |
testcase_43 | AC | 4 ms
6,940 KB |
testcase_44 | AC | 3 ms
6,944 KB |
testcase_45 | AC | 3 ms
6,944 KB |
testcase_46 | AC | 4 ms
6,944 KB |
testcase_47 | AC | 4 ms
6,944 KB |
testcase_48 | AC | 3 ms
6,940 KB |
testcase_49 | AC | 3 ms
6,940 KB |
testcase_50 | AC | 4 ms
6,940 KB |
testcase_51 | AC | 4 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define ALL(x) ::std::begin(x), ::std::end(x) using namespace std; template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >; // generated by oj-template v4.8.0 (https://github.com/online-judge-tools/template-generator) const std::string YES = "Yes"; const std::string NO = "No"; int main() { // input int h, w, up, down, left, right; int64_t k, p; cin >> h >> w >> up >> down >> left >> right >> k >> p; int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty; -- sx; -- sy; -- tx; -- ty; vector<string> c(h); REP (y, h) { cin >> c[y]; } // solve vector<vector<int64_t>> dist(h, vector<int64_t>(w, INT64_MAX)); reversed_priority_queue<tuple<int64_t, int, int>> que; dist[sy][sx] = 0; que.emplace(0, sy, sx); while (not que.empty()) { auto [dist_y_x, y, x] = que.top(); que.pop(); if (dist_y_x > dist[y][x]) { continue; } REP (i, 4) { const int dy[4] = {-1, 1, 0, 0}; const int dx[4] = {0, 0, 1, -1}; int ny = y + dy[i]; int nx = x + dx[i]; if (0 <= ny and ny < h and 0 <= nx and nx < w) { if (c[ny][nx] == '#') { continue; } const int cost[4] = {up, down, right, left}; int64_t ndist = dist[y][x] + cost[i] + (c[ny][nx] == '@' ? p : 0); if (ndist < dist[ny][nx]) { dist[ny][nx] = ndist; que.emplace(ndist, ny, nx); } } } } bool ans = dist[ty][tx] <= k; // output cout << (ans ? YES : NO) << '\n'; return 0; }