結果
| 問題 |
No.424 立体迷路
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2020-03-05 21:45:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,549 bytes |
| コンパイル時間 | 669 ms |
| コンパイル使用メモリ | 75,348 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 02:08:54 |
| 合計ジャッジ時間 | 1,510 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 19 WA * 2 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:34:20: warning: narrowing conversion of '(((long long int)z.dta::x) + ar4[i].std::pair<long long int, long long int>::first)' from 'long long int' to 'int' [-Wnarrowing]
34 | a.push({z.x+ar4[i].first,z.y+ar4[i].second});
| ~~~^~~~~~~~~~~~~
main.cpp:34:37: warning: narrowing conversion of '(((long long int)z.dta::y) + ar4[i].std::pair<long long int, long long int>::second)' from 'long long int' to 'int' [-Wnarrowing]
34 | a.push({z.x+ar4[i].first,z.y+ar4[i].second});
| ~~~^~~~~~~~~~~~~~
main.cpp:42:20: warning: narrowing conversion of '(((long long int)z.dta::x) + (ar4[i].std::pair<long long int, long long int>::first * 2))' from 'long long int' to 'int' [-Wnarrowing]
42 | a.push({z.x+ar4[i].first*2,z.y+ar4[i].second*2});
| ~~~^~~~~~~~~~~~~~~
main.cpp:42:39: warning: narrowing conversion of '(((long long int)z.dta::y) + (ar4[i].std::pair<long long int, long long int>::second * 2))' from 'long long int' to 'int' [-Wnarrowing]
42 | a.push({z.x+ar4[i].first*2,z.y+ar4[i].second*2});
| ~~~^~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <queue>
using namespace std;
struct dta{
int x,y;
};
using ll = long long;
using P = pair<ll,ll>;
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
char mp[50][50];
bool lck[50][50];
int main(){
int h,w;cin>>h>>w;
int sx,sy,gx,gy;cin>>sx>>sy>>gx>>gy;sx--;sy--;gx--;gy--;
for(int i = 0; h > i; i++){
for(int j = 0; w > j; j++){
cin>>mp[i][j];
}
}
queue<dta> a;
a.push({sx,sy});
lck[sx][sy] = true;
while(!a.empty()){
dta z = a.front();a.pop();
if(z.x == gx && z.y == gy){
cout << "YES" << endl;
return 0;
}
//隣り合った高さのdistanceが1以下だったら通れる
for(int i = 0; 4 > i; i++){
if(0 > z.x+ar4[i].first || z.x+ar4[i].first >= h || 0 > z.y+ar4[i].second || z.y+ar4[i].second >= w)continue;
if(!lck[z.x+ar4[i].first][z.y+ar4[i].second] && abs(mp[z.x][z.y]-mp[z.x+ar4[i].first][z.y+ar4[i].second]) < 2){
lck[z.x+ar4[i].first][z.y+ar4[i].second] = true;
a.push({z.x+ar4[i].first,z.y+ar4[i].second});
}
}
//同じ高さの2つ先のdistanceが0以下だったら通れる
for(int i = 0; 4 > i; i++){
if(0 > z.x+ar4[i].first || z.x+ar4[i].first >= h || 0 > z.y+ar4[i].second || z.y+ar4[i].second >= w)continue;
if(!lck[z.x+ar4[i].first*2][z.y+ar4[i].second*2] && abs(mp[z.x][z.y]-mp[z.x+ar4[i].first*2][z.y+ar4[i].second*2]) < 1){
lck[z.x+ar4[i].first*2][z.y+ar4[i].second*2] = true;
a.push({z.x+ar4[i].first*2,z.y+ar4[i].second*2});
}
}
}
cout << "NO" << endl;
}