結果
| 問題 | No.61 リベリオン | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-09-05 14:35:29 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 1,723 bytes | 
| コンパイル時間 | 982 ms | 
| コンパイル使用メモリ | 115,352 KB | 
| 実行使用メモリ | 6,940 KB | 
| 最終ジャッジ日時 | 2024-06-12 04:10:42 | 
| 合計ジャッジ時間 | 1,740 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 3 WA * 1 | 
コンパイルメッセージ
/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);
  }
}
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 (u; 1..vg + 1) {
          auto x = (ph.x + pv.x * t + pv.x / vg * u) % (2 * w);
          auto y = (ph.y + pv.y * t + pv.y / vg * u) % (2 * h);
          buf[y][x] = true;
        }
      }
    }
    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");
  }
}
            
            
            
        