結果
| 問題 |
No.8063 幅優先探索
|
| コンテスト | |
| ユーザー |
s0j1san
|
| 提出日時 | 2020-04-01 21:53:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 703 bytes |
| コンパイル時間 | 2,050 ms |
| コンパイル使用メモリ | 179,560 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2024-06-27 10:38:41 |
| 合計ジャッジ時間 | 3,173 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 2 RE * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> mx={0,1,0,-1};vector<int> my={1,0,-1,0};
int R,C,sy,sx,gy,gx,y,x,Y,X;scanf("%d %d %d %d %d %d",&R,&C,&sy,&sx,&gy,&gx);
vector<vector<char>> c(R,vector<char>(C));vector<vector<int>> dist(R,vector<int>(C,-1));
for(int i=0;i<R;i++)for(int j=0;j<C;j++)cin>>c[i][j];
queue<int> que;que.push(sy-1);que.push(sx-1);dist[sy-1][sx-1]=0;
while(!que.empty())
{
y=que.front();que.pop();x=que.front();que.pop();
for(int i=0;i<4;i++)
{
Y=y+my[i];X=x+mx[i];
if(c[Y][X]!='.'||dist[Y][X]!=-1)continue;
dist[Y][X]=dist[y][x]+1;
que.push(Y);que.push(X);
if(Y==gy-1&&X==gx-1){printf("%d\n",dist[gy-1][gx-1]);return 0;}
}
}
}
s0j1san