結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー 蜜蜂蜜蜂
提出日時 2022-05-06 01:40:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 177 ms / 3,000 ms
コード長 1,781 bytes
コンパイル時間 4,236 ms
コンパイル使用メモリ 236,856 KB
実行使用メモリ 11,752 KB
最終ジャッジ日時 2023-09-18 12:02:10
合計ジャッジ時間 8,875 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 84 ms
7,028 KB
testcase_08 AC 37 ms
6,960 KB
testcase_09 AC 77 ms
7,024 KB
testcase_10 AC 84 ms
6,976 KB
testcase_11 AC 89 ms
6,976 KB
testcase_12 AC 80 ms
7,316 KB
testcase_13 AC 72 ms
7,040 KB
testcase_14 AC 103 ms
11,532 KB
testcase_15 AC 104 ms
11,656 KB
testcase_16 AC 20 ms
7,020 KB
testcase_17 AC 177 ms
11,752 KB
testcase_18 AC 20 ms
7,088 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 111 ms
10,900 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 46 ms
7,084 KB
testcase_25 AC 69 ms
7,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:70:10: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   70 |     auto [enemy,i,j]=que.top();
      |          ^

ソースコード

diff #

//g++ 2.cpp -std=c++14 -O2 -I .
#include <bits/stdc++.h>
using namespace std;

#include <atcoder/all>
using namespace atcoder;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vst = vector<string>;
using vvst = vector<vst>;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pq_big(T) priority_queue<T,vector<T>,less<T>>
#define pq_small(T) priority_queue<T,vector<T>,greater<T>>
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)
#define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end())

using T = tuple<ll,int,int>;

vi dx = {1,0,-1,0};
vi dy = {0,1,0,-1};

bool ok(int h,int w,int i,int j){
  if(i<0||h<=i||j<0||w<=j){
    return false;
  }
  return true;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int h,w,x,y;
  cin>>h>>w>>x>>y;
  x--;y--;

  vvll a(h,vll(w)),seen(h,vll(w,0));
  rep(i,0,h){
    rep(j,0,w){
      cin>>a[i][j];
    }
  }
  seen[x][y]=1;

  ll p=a[x][y];
  pq_small(T) que;

  rep(d,0,4){
    int ni=x+dx[d],nj=y+dy[d];
    if(ok(h,w,ni,nj)){
      que.push({a[ni][nj],ni,nj});
    }
  }

  while(!que.empty()){
    auto [enemy,i,j]=que.top();
    que.pop();

    if(seen[i][j]==1)continue;

    if(p>enemy){
      seen[i][j]=1;
      p+=enemy;

      rep(d,0,4){
        int ni=i+dx[d],nj=j+dy[d];
        if(ok(h,w,ni,nj)&&seen[ni][nj]==0){
          que.push({a[ni][nj],ni,nj});
        }
      }
    }
  }

  rep(i,0,h){
    rep(j,0,w){
      if(seen[i][j]==0){
        cout<<"No\n";
        return 0;
      }
    }
  }
  cout<<"Yes\n";
}
0