結果
問題 | No.424 立体迷路 |
ユーザー | kotamanegi |
提出日時 | 2016-09-22 22:51:05 |
言語 | C++11 (gcc 11.4.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,964 bytes |
コンパイル時間 | 1,105 ms |
コンパイル使用メモリ | 91,736 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-17 15:01:26 |
合計ジャッジ時間 | 3,602 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | AC | 1 ms
6,816 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | AC | 1 ms
6,820 KB |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | AC | 1 ms
6,816 KB |
testcase_19 | RE | - |
testcase_20 | AC | 2 ms
6,816 KB |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include<map> #include <iomanip> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(int i = 0;i < n;++i) #define LONGINF 1000000000000000000 int can_arrive[100][100] = {}; int blocks[100][100] = {}; int plmi(int a, int b) { if (a == b) { return 1; } if (a == b - 1) { return 1; } if (a == b + 1) { return 1; } return 0;//±1 } int main() { int h, w; cin >> h >> w; queue<pair<int, int>> start; int goalx, goaly; REP(i, 1) { int a, b, c, d; cin >> a >> b >> goalx >> goaly; pair<int, int> hoge = make_pair(a, b); start.push(hoge); } can_arrive[start.front().first][start.front().second] = 1; for (int i = 1;i <= h;++i) { string s; cin >> s; for (int q = 1; q <= w;++q) { blocks[i][q] = (int)s[q - 1] - (int)'0'; } } while (start.empty() == false) { int x = start.front().first; int y = start.front().second; start.pop(); if (x != 1) { if (plmi(blocks[x][y], blocks[x - 1][y]) == true) { if (can_arrive[x - 1][y] == false) { can_arrive[x - 1][y] = true; start.push(make_pair(x - 1, y)); } } if (x != 2) { if (blocks[x][y] >= blocks[x - 2][y]) { if (can_arrive[x - 2][y] == false) { can_arrive[x - 2][y] = true; start.push(make_pair(x - 2, y)); } } } } if (x != h) { if (plmi(blocks[x][y], blocks[x + 1][y]) == true) { if (can_arrive[x + 1][y] == false) { can_arrive[x + 1][y] = true; start.push(make_pair(x + 1, y)); } } if (x - 1 != h) { if (blocks[x][y] >= blocks[x+2][y]) { if (can_arrive[x+2][y] == false) { can_arrive[x+2][y] = true; start.push(make_pair(x + 2, y)); } } } } if (y != 1) { if (plmi(blocks[x][y], blocks[x][y - 1]) == true) { if (can_arrive[x][y - 1] == false) { can_arrive[x][y - 1] = true; start.push(make_pair(x, y - 1)); } } if (y != 2) { if (blocks[x][y] >= blocks[x][y - 2]) { if (can_arrive[x][y - 2] == false) { can_arrive[x][y - 2] = true; start.push(make_pair(x, y - 2)); } } } } if (y != w) { if (plmi(blocks[x][y], blocks[x][y + 1]) == true) { if (can_arrive[x][y + 1] == false) { can_arrive[x][y + 1] = true; start.push(make_pair(x, y + 1)); } } if (y - 1 != w) { if (blocks[x][y] >= blocks[x][y + 2]) { if (can_arrive[x][y + 2] == false) { can_arrive[x][y + 2] = true; start.push(make_pair(x, y + 2)); } } } } } if (can_arrive[goalx][goaly] == true) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }