結果
| 問題 |
No.61 リベリオン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-05 14:26:48 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,990 bytes |
| コンパイル時間 | 765 ms |
| コンパイル使用メモリ | 116,896 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 04:10:19 |
| 合計ジャッジ時間 | 1,583 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 3 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`
ソースコード
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.conv, std.stdio, std.typecons;
struct point {
int 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);
}
}
const auto divisors = [
[], [1], [1, 2], [1, 3], [1, 2, 4], [1, 5], [1, 2, 3, 6],
[1, 7], [1, 2, 4, 8], [1, 3, 9], [1, 2, 5, 10], [1, 11],
[1, 2, 3, 4, 6, 12], [1, 13], [1, 2, 7, 14], [1, 3, 5, 15]
];
void main()
{
auto q = readln.chomp.to!int;
foreach (_; 0..q) {
auto rd = readln.split.map!(to!int);
auto w = rd[0], h = rd[1], d = rd[2];
auto pm = point(rd[3], rd[4]), ph = point(rd[5], rd[6]), pv = point(rd[7], rd[8]);
if (pv.x < 0) {
pm = point(w - pm.x, pm.y);
ph = point(w - ph.x, ph.y);
pv = point(-pv.x, pv.y);
}
if (pv.y < 0) {
pm = point(pm.x, h - pm.y);
ph = point(ph.x, h - ph.y);
pv = point(pv.x, -pv.y);
}
auto hw = h * w / gcd(h, w);
auto buf = new bool[][](2 * h, 2 * w);
auto vg = gcd(pv.x, pv.y);
foreach (t; 1..min(d, 2 * hw) + 1) {
if (pv.x == 0 || pv.y == 0 || pv.x == pv.y) {
foreach (u; 0..max(pv.x, pv.y)) {
auto x = (ph.x + pv.x * t + u * (pv.x == 0 ? 0 : 1)) % (2 * w);
auto y = (ph.y + pv.y * t + u * (pv.y == 0 ? 0 : 1)) % (2 * h);
buf[y][x] = true;
}
} else {
foreach (dv; divisors[vg]) {
auto x = (ph.x + pv.x * t + pv.x / dv) % (2 * w);
auto y = (ph.y + pv.y * t + pv.y / dv) % (2 * h);
buf[y][x] = true;
}
}
}
//buf.each!(a => a.map!(a => a ? "o" : ".").join.writeln);
auto rx = 2 * w - pm.x;
auto ry = 2 * h - pm.y;
auto r = buf[pm.y][pm.x] || buf[ry][pm.x] || buf[pm.y][rx] || buf[ry][rx];
writeln(r ? "Hit" : "Miss");
}
}