結果
| 問題 |
No.61 リベリオン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-09 15:15:24 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,736 bytes |
| コンパイル時間 | 788 ms |
| コンパイル使用メモリ | 116,592 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 07:15:43 |
| 合計ジャッジ時間 | 1,908 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 2 WA * 2 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;
void main() {
int Q = readln.chomp.to!int;
foreach (i; 0..Q) {
auto s = readln.split.map!(to!int);
int W, H, D, mx, my, hx, hy, vx, vy;
W = s[0], H = s[1], D = s[2], mx = s[3], my = s[4];
hx = s[5], hy = s[6], vx = s[7], vy = s[8];
auto g = gcd(abs(vx), abs(vy));
auto used = new bool[][][][](W+1, H+1, 2, 2);
bool hit = false;
bool end = false;
foreach (_; 0..D) {
foreach (j; 0..g) {
hx += vx/g, hy += vy/g;
if (hx > W) {
int p = (hx - W) / W;
int q = (hx - W) % W;
if (p % 2 == 1) {
hx = W - q;
vx = -abs(vx);
}
else {
hx = q;
vx = abs(vx);
}
}
else if (hx < 0) {
int p = (-hx) / W;
int q = (-hx) % W;
if (p % 2 == 0) {
hx = W - q;
vx = -abs(vx);
}
else {
hx = q;
vx = abs(vx);
}
}
if (hy > H) {
int p = (hy - H) / H;
int q = (hy - H) % H;
if (p % 2 == 1) {
hy = H - q;
vy = -abs(vy);
}
else {
hy = q;
vy = abs(vy);
}
}
else if (hy < 0) {
int p = (-hy) / H;
int q = (-hy) % H;
if (p % 2 == 0) {
hy = H - q;
vy = -abs(vy);
}
else {
hy = q;
vy = abs(vy);
}
}
if (hx == mx && hy == my) {
hit = true;
end = true;
break;
}
if (used[hx][hy][vx>0][vy>0]) {
end = true;
break;
}
used[hx][hy][vx>0][vy>0] = true;
}
if (end)
break;
}
writeln(hit ? "Hit" : "Miss");
}
}