結果
問題 |
No.240 ナイト散歩
|
ユーザー |
![]() |
提出日時 | 2015-12-21 01:54:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 755 bytes |
コンパイル時間 | 428 ms |
コンパイル使用メモリ | 58,140 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 21:14:09 |
合計ジャッジ時間 | 1,296 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 WA * 2 |
ソースコード
#include <iostream> #include <vector> #include <string> using namespace std; bool board[4][10][10]; int main() { int x, y; cin >> x >> y; x = abs(x), y = abs(y); if(x > 10 || y > 10) { cout << "NO" << endl; return 0; } int dx[] = { 1, 2, -1, -2, 1, 2, -1, -2 }, dy[] = { 2, 1, 2, 1, -2, -1, -2, -1 }; board[0][0][0] = true; for(int i = 0; i < 3; i++) { for(int j = 0; j < 10; j++) { for(int k = 0; k < 10; k++) { for(int l = 0; l < 8; l++) { if(board[i][j][k]) { board[i + 1][j][k] = true; int nj = j + dy[l], nk = k + dx[l]; if(nj < 0 || 10 <= nj || nk < 0 || 10 <= nk) continue; board[i + 1][j + dy[l]][k + dx[l]] = true; } } } } } cout << (board[3][y][x] ? "YES" : "NO") << endl; }