結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー CleyLCleyL
提出日時 2023-06-30 13:43:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,145 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 83,728 KB
実行使用メモリ 37,364 KB
最終ジャッジ日時 2023-09-21 07:21:21
合計ジャッジ時間 7,817 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 100 ms
5,292 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 78 ms
5,304 KB
testcase_13 AC 159 ms
5,712 KB
testcase_14 AC 82 ms
5,340 KB
testcase_15 AC 73 ms
5,616 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct st{
  int h,w;
  int a;
  bool re;
};

int main(){
  int h,w;cin>>h>>w;
  vector<vector<int>> A(h,vector<int>(w));
  vector<vector<int>> nw(h,vector<int>(w));
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      cin>>A[i][j];
    }
  }
  queue<st> Z;
  Z.push({0,0,A[0][0],false});
  while(Z.size()){
    auto z = Z.front(); Z.pop();
    if(z.h+1 == h && z.w+1 == w && z.a > A[z.h][z.w]){
      cout << "Yes" << endl;
      return 0;
    }
    if(nw[z.h][z.w] < z.a){
      nw[z.h][z.w] = z.a;
    }else{
      continue;
    }
    if(z.h+1 != h){
      if(z.a > A[z.h+1][z.w]){
        Z.push({z.h+1, z.w, z.a+A[z.h+1][z.w], z.re});
      }else if(!z.re){
        if(!(z.h+1 == h && z.w == w))Z.push({z.h+1, z.w, z.a, true});
      }else{
        continue;
      }
    }

    if(z.w+1 != w){
      if(z.a > A[z.h][z.w+1]){
        Z.push({z.h, z.w+1, z.a+A[z.h][z.w+1], z.re});
      }else if(!z.re){
        if(!(z.h == h && z.w+1 == w))Z.push({z.h, z.w+1, z.a, true});
      }else{
        continue;
      }
    }
  }
  cout << "No" << endl;
}
0