結果

問題 No.323 yuki国
ユーザー ciel
提出日時 2015-12-18 04:09:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3,901 ms / 5,000 ms
コード長 930 bytes
コンパイル時間 1,227 ms
コンパイル使用メモリ 83,732 KB
実行使用メモリ 93,312 KB
最終ジャッジ日時 2024-07-26 18:22:13
合計ジャッジ時間 39,967 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

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

#include <iostream>
#include <string>
#include <queue>
#include <map>
using namespace std;
typedef struct{
int x;
int y;
}dir;
const dir D[]={
{0,-1},{0,1},{-1,0},{1,0}
};
int main(){
int H,W,A,Sx,Sy,B,Gx,Gy;
cin>>H>>W>>A>>Sy>>Sx>>B>>Gy>>Gx;
vector<string>v(H);
for(int i=0;i<H;i++)cin>>v[i];
queue<tuple<int,int,int>>q;
q.emplace(Sx,Sy,A);
map<tuple<int,int,int>,int>depth={ {make_tuple(Sx,Sy,A),0} };
for(;!q.empty();){
auto cur=q.front();q.pop();
int cx=get<0>(cur),cy=get<1>(cur),cw=get<2>(cur);
for(auto &d:D){
if(0<=cx+d.x&&cx+d.x<W && 0<=cy+d.y&&cy+d.y<H){
int w=cw+(v[cy+d.y][cx+d.x]=='*' ? 1 : -1);
if(1<=w && w<=A+B+H+W){
if(cx+d.x==Gx && cy+d.y==Gy && w==B){
cout<<"Yes"<<endl;
return 0;
}
auto nxt=make_tuple(cx+d.x,cy+d.y,w);
if(depth.find(nxt)==depth.end()){
q.push(nxt);
depth[nxt]=depth[cur]+1;
}
}
}
}
}
cout<<"No"<<endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0