結果
問題 | No.424 立体迷路 |
ユーザー | naoshi65536 |
提出日時 | 2016-09-22 23:28:34 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 1,485 bytes |
コンパイル時間 | 206 ms |
コンパイル使用メモリ | 26,812 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-18 16:50:34 |
合計ジャッジ時間 | 1,247 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,380 KB |
testcase_12 | AC | 2 ms
4,384 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 1 ms
4,384 KB |
testcase_15 | AC | 1 ms
4,380 KB |
testcase_16 | AC | 2 ms
4,380 KB |
testcase_17 | AC | 1 ms
4,376 KB |
testcase_18 | AC | 1 ms
4,380 KB |
testcase_19 | AC | 2 ms
4,380 KB |
testcase_20 | AC | 2 ms
4,376 KB |
testcase_21 | AC | 2 ms
4,380 KB |
testcase_22 | AC | 2 ms
4,380 KB |
testcase_23 | AC | 1 ms
4,380 KB |
testcase_24 | AC | 15 ms
4,376 KB |
testcase_25 | AC | 12 ms
4,376 KB |
コンパイルメッセージ
main.cpp:74:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] main() ^ main.cpp: In function ‘int main()’: main.cpp:81:20: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations] while (gets(buf[n]) != NULL) { ^ In file included from main.cpp:1: /usr/include/stdio.h:583:14: note: declared here extern char *gets (char *__s) __wur __attribute_deprecated__; ^~~~ main.cpp:81:20: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations] while (gets(buf[n]) != NULL) { ^ In file included from main.cpp:1: /usr/include/stdio.h:583:14: note: declared here extern char *gets (char *__s) __wur __attribute_deprecated__; ^~~~ /tmp/ccFWi6Pn.o: In function `main': main.cpp:(.text.startup+0x48): warning: the `gets' function is dangerous and should not be used.
ソースコード
#include <stdio.h> char buf[50][100]; char visit[50][100]; int solve(int x, int y, int gx, int gy) { int dx, dy; if (visit[y][x]) { return 0; } visit[y][x] = 1; fprintf(stderr, "in %d %d %d %d\n", x, y, gx, gy); if (x == gx && y == gy) { fprintf(stderr, "OK\n"); return 1; } int base = buf[y][x]; fprintf(stderr, "baseptr=%s\n", buf[y]); fprintf(stderr, "base = %c\n", base); if (base == 0) { fprintf(stderr, "fail\n"); return 0; } int dxdy[4][2] = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 }, }; for (int i = 0; i < 4; i++) { dx = dxdy[i][0]; dy = dxdy[i][1]; int xx = x + dx; int yy = y + dy; if (xx < 0 || yy < 0 || xx >= 50 || yy >= 50) { continue; } int c = buf[yy][xx]; if (c == base - 1 || c == base + 1 || c == base) { if (solve(xx, yy, gx, gy)) { fprintf(stderr, "solved\n"); return 1; } } xx = x + dx * 2; yy = y + dy * 2; if (xx < 0 || yy < 0 || xx >= 50 || yy >= 50) { continue; } int xx2 = x + dx; int yy2 = y + dy; c = buf[yy2][xx2]; if (c >= base) { continue; } c = buf[yy][xx]; if (c == base) { if (solve(xx, yy, gx, gy)) { fprintf(stderr, "solved\n"); return 1; } } } return 0; } main() { int w, h, sx, sy, gx, gy; scanf("%d %d\n", &h, &w); scanf("%d %d %d %d\n", &sx, &sy, &gx, &gy); int n = 0; while (gets(buf[n]) != NULL) { n++; } sx--; sy--; gx--; gy--; if (solve(sy, sx, gy, gx)) { puts("YES"); } else { puts("NO"); } }