結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2016-09-20 14:08:15 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 953 bytes |
コンパイル時間 | 816 ms |
コンパイル使用メモリ | 120,932 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-12 04:31:01 |
合計ジャッジ時間 | 2,028 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import std.algorithm, std.array, std.container, std.range, std.bitmanip;import std.numeric, std.math, std.bigint, std.random, core.bitop;import std.string, std.regex, std.conv, std.stdio, std.typecons;void main(){auto rd = readln.split.map!(to!int);auto x = rd[0], y = rd[1];auto j1 = jump([point(0, 0)]);auto j2 = jump(j1);auto j3 = jump(j2);auto j = j1 ~ j2 ~ j3;writeln(j.canFind(point(x, y)) ? "YES" : "NO");}point[] jump(point[] pi){return pi.map!(p => knightJumps.map!(a => p + a).array).reduce!("a ~ b");}struct Point(T) {T x, y;point opBinary(string op)(point rhs) {static if (op == "+") return point(x + rhs.x, y + rhs.y);else static if (op == "-") return point(x - rhs.x, y - rhs.y);}}alias Point!int point;const auto knightJumps = [point(-2, -1), point(-2, +1), point(-1, -2), point(-1, +2),point(+1, -2), point(+1, +2), point(+2, -1), point(+2, +1)];