結果
| 問題 |
No.61 リベリオン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-09 15:16:40 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 289 ms / 5,000 ms |
| コード長 | 1,778 bytes |
| コンパイル時間 | 1,016 ms |
| コンパイル使用メモリ | 107,520 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-12 07:16:11 |
| 合計ジャッジ時間 | 2,145 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 |
コンパイルメッセージ
/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, core.stdc.stdio;
void main() {
int Q;
scanf("%d", &Q);
foreach (i; 0..Q) {
int W, H, D, mx, my, hx, hy, vx, vy;
scanf("%d %d %d %d %d %d %d %d %d", &W, &H, &D, &mx, &my, &hx, &hy, &vx, &vy);
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;
while (hx < 0 || hx > W) {
if (hx > W) {
hx = 2 * W - hx;
vx *= -1;
}
else if (hx < 0) {
hx = -hx;
vx *= -1;
}
}
while (hy < 0 || hy > H) {
if (hy > H) {
hy = 2 * H - hy;
vy *= -1;
}
else if (hy < 0) {
hy = -hy;
vy *= -1;
}
}
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");
}
}