結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
蜜蜂
|
| 提出日時 | 2022-05-06 01:40:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 161 ms / 3,000 ms |
| コード長 | 1,781 bytes |
| コンパイル時間 | 4,159 ms |
| コンパイル使用メモリ | 239,916 KB |
| 実行使用メモリ | 12,120 KB |
| 最終ジャッジ日時 | 2024-07-05 02:59:43 |
| 合計ジャッジ時間 | 6,851 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:70:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
70 | auto [enemy,i,j]=que.top();
| ^
ソースコード
//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";
}
蜜蜂