結果

問題 No.323 yuki国
ユーザー betit0919
提出日時 2020-05-09 17:02:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 184 ms / 5,000 ms
コード長 1,784 bytes
コンパイル時間 1,238 ms
コンパイル使用メモリ 126,140 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 22:04:01
合計ジャッジ時間 4,442 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int H,W,A,Si,Sj,B,Gi,Gj;
cin>>H>>W>>A>>Si>>Sj>>B>>Gi>>Gj;
vector<string>M(H);
REP(i,H)cin>>M[i];
vector<vector<vector<bool>>> ans(H, vector<vector<bool>>(W, vector<bool>(4000)));
queue<tuple<int,int,int>> q;
q.push(tie(Si,Sj,A));
const pair<int,int> moves[] = {
{-1,0}, {1,0}, {0,-1}, {0,1},
};
while(!q.empty()){
tuple<int,int,int>cur=q.front();q.pop();
for(auto &move:moves){
int x=get<0>(cur);
int y=get<1>(cur);
int s=get<2>(cur);
int nextx=x+move.first;
int nexty=y+move.second;
if(nextx<0 || nexty<0 || nextx>=H || nexty>=W){
continue;
}
int nexts=s+(M[nextx][nexty]=='*'?1:-1);
if(nexts<=0 || nexts>=3800){
continue;
}
if(!ans[nextx][nexty][nexts]){
ans[nextx][nexty][nexts]=true;
q.push(tie(nextx,nexty,nexts));
}
}
}
cout<<(ans[Gi][Gj][B]?"Yes":"No")<<endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0