結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
shinchan
|
| 提出日時 | 2022-05-20 22:31:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 3,000 ms |
| コード長 | 1,712 bytes |
| コンパイル時間 | 2,044 ms |
| コンパイル使用メモリ | 207,428 KB |
| 最終ジャッジ日時 | 2025-01-29 10:58:58 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:53:9: warning: ‘now’ may be used uninitialized [-Wmaybe-uninitialized]
53 | if(d >= now) {
| ^~
main.cpp:17:8: note: ‘now’ was declared here
17 | ll now;
| ^~~
ソースコード
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
ll h, w, y, x;
cin >> h >> w >> y >> x;
ll now;
y--; x--;
vector a(h, vector(w, 0LL));
multiset<tuple<ll, int, int>> ms;
rep(i, h) rep(j, w) {
cin >> a[i][j];
if(i == y && j == x) {
now = a[i][j];
}
}
// cout << "aa" << endl;
vector seen(h, vector(w, 0));
seen[y][x] = 1;
int dy[4] = {-1, 0, 0, 1};
int dx[4] = {0, -1, 1, 0};
rep(k, 4) {
// cout << k << endl;
int i = dy[k] + y;
int j = dx[k] + x;
if(i < 0 || i > h - 1 || j < 0 || j > w - 1) continue;
if(seen[i][j]) continue;
seen[i][j] = 1;
ms.insert({a[i][j], i, j});
}
// cout << "aa" << endl;
while(!ms.empty()) {
// cout << "Jj" << endl;
auto [d, ii, jj] = *ms.begin();
ms.erase(ms.begin());
// cout << ii << " " << jj << " " << d << " " << now << endl;
if(d >= now) {
cout << "No" << endl;
return 0;
}
now += d;
rep(k, 4) {
int i = ii + dy[k];
int j = jj + dx[k];
if(i < 0 || i >= h || j < 0 || j >= w) continue;
if(seen[i][j]) continue;
seen[i][j] = 1;
ms.insert({a[i][j], i, j});
}
}
cout << "Yes" << endl;
return 0;
}
shinchan