結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-20 22:57:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,218 bytes |
| コンパイル時間 | 2,293 ms |
| コンパイル使用メモリ | 211,448 KB |
| 最終ジャッジ日時 | 2025-01-29 11:20:10 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 6 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int H, W, sy, sx;
cin >> H >> W >> sy >> sx;
vector A(H, vector<ll>(W));
rep(i, H) rep(j, W) cin >> A[i][j];
sy--, sx--;
vector seen(H, vector<bool>(W));
seen[sy][sx] = true;
using T = tuple<ll, int, int>;
priority_queue<T, vector<T>, greater<T>> pq;
pq.push({A[sy][sx], sy, sx});
ll cur = 0;
while (!pq.empty()) {
auto [enemy, y, x] = pq.top();
pq.pop();
if (!(y == sy && x == sx) && enemy > cur)
break;
cur += enemy;
rep(i, 4) {
int ny = y + dy[i], nx = x + dx[i];
if (ny < 0 || ny >= H || nx < 0 || nx >= W)
continue;
if (seen[ny][nx])
continue;
seen[ny][nx] = true;
pq.push({A[ny][nx], ny, nx});
}
}
rep(i, H) rep(j, W) {
if (!seen[i][j]) {
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
return 0;
}