結果
問題 | No.1948 足し算するだけのパズルゲーム(1) |
ユーザー |
![]() |
提出日時 | 2022-05-20 22:08:01 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,250 bytes |
コンパイル時間 | 11,239 ms |
コンパイル使用メモリ | 288,252 KB |
最終ジャッジ日時 | 2025-01-29 10:42:34 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 1 TLE * 10 MLE * 1 |
ソースコード
#pragma GCC target("avx2")#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")#include<bits/stdc++.h>using namespace std;using ll = long long;const int INF = 1e9;const ll inf = 1LL<<60;void solve() {int h, w; cin >> h >> w;vector<vector<ll>> a(h, vector<ll>(w));for (int i=0; i<h; i++) for (int j=0; j<w; j++) cin >> a[i][j];queue<vector<ll>> q;q.push({0, 0, a[0][0], 0});while (q.size()) {auto now = q.front(); q.pop();int i = now[0], j = now[1];if (i == h-1 && j == w-1) {cout << "Yes" << '\n';return;}ll lv = now[2], state = now[3];if (i + 1 < h) {if (lv > a[i+1][j]) {q.push({i+1, j, lv+a[i+1][j], state});} else {if (state == 1) continue;if (i+1 == h-1 && j == w-1) continue;q.push({i+1, j, lv, state+1});}}if (j+1 < w) {if (lv > a[i][j+1]) {q.push({i, j+1, lv+a[i][j+1], state});} else {if (state == 1) continue;if (i == h-1 && j+1 == w-1) continue;q.push({i, j+1, lv, state+1});}}}cout << "No" << '\n';}int main() {ios::sync_with_stdio(false);std::cin.tie(nullptr);// int t; cin >> t;/*while (t--)*/ solve();}