結果
| 問題 | No.424 立体迷路 |
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-09-22 23:32:39 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,547 bytes |
| 記録 | |
| コンパイル時間 | 363 ms |
| コンパイル使用メモリ | 79,336 KB |
| 最終ジャッジ日時 | 2026-03-26 13:58:24 |
| 合計ジャッジ時間 | 669 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int bfs()':
main.cpp:20:55: error: 'INT32_MAX' was not declared in this scope
20 | for (int j = 0; j < w; j++) d[i][j] = INT32_MAX;
| ^~~~~~~~~
main.cpp:6:1: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
5 | #include <cmath>
+++ |+#include <cstdint>
6 | using namespace std;
main.cpp:32:136: error: 'INT32_MAX' was not declared in this scope
32 | if (0 <= nx && nx < h && 0 <= ny && ny < w && abs(MAZE[nx][ny] - MAZE[p.first][p.second]) <= 1 && d[nx][ny] == INT32_MAX) {
| ^~~~~~~~~
main.cpp:32:136: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:40:133: error: 'INT32_MAX' was not declared in this scope
40 | if (0 <= nx && nx < h && 0 <= ny && ny < w && (MAZE[nx][ny] - MAZE[p.first][p.second]) == 0 && d[nx][ny] == INT32_MAX) {
| ^~~~~~~~~
main.cpp:40:133: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp: In function 'int main()':
main.cpp:66:22: error: 'INT32_MAX' was not declared in this scope
66 | if (bfs() != INT32_MAX)cout << "YES" << endl;
| ^~~~~~~~~
main.cpp:66:22: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
typedef pair<int, int> P;
int MAZE[51][51];
int w, h;
int sx, sy, gx, gy;
int d[51][51];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int bfs() {
queue<P> que;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) d[i][j] = INT32_MAX;
}
que.push(P(sx, sy));
d[sx][sy] = 0;
while (que.size()) {
P p = que.front(); que.pop();
if (p.first == gx && p.second == gy) break;
for (int i = 0; i < 4; i++) {
int nx = p.first + dx[i], ny = p.second + dy[i];
if (0 <= nx && nx < h && 0 <= ny && ny < w && abs(MAZE[nx][ny] - MAZE[p.first][p.second]) <= 1 && d[nx][ny] == INT32_MAX) {
que.push(P(nx, ny));
d[nx][ny] = d[p.first][p.second] + 1;
}
}
for (int i = 0; i < 4; i++) {
int nx = p.first + 2*dx[i], ny = p.second + 2*dy[i];
if (0 <= nx && nx < h && 0 <= ny && ny < w && (MAZE[nx][ny] - MAZE[p.first][p.second]) == 0 && d[nx][ny] == INT32_MAX) {
if ((nx == p.first && MAZE[nx][(ny + p.second) / 2] < MAZE[nx][ny]) || (ny == p.second && MAZE[(nx + p.first) / 2][ny] < MAZE[nx][ny])) {
que.push(P(nx, ny));
d[nx][ny] = d[p.first][p.second] + 1;
}
}
}
}
return d[gx][gy];
}
int main()
{
cin >> h >> w >> sx >> sy >> gx >> gy;
sx--; sy--; gx--; gy--;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
char c;
cin >> c;
MAZE[i][j] = c-'0';
}
}
if (bfs() != INT32_MAX)cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}
kurenai3110