結果
| 問題 | No.61 リベリオン | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-03-09 14:55:27 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,649 bytes | 
| コンパイル時間 | 701 ms | 
| コンパイル使用メモリ | 107,344 KB | 
| 実行使用メモリ | 9,120 KB | 
| 最終ジャッジ日時 | 2024-06-12 07:15:41 | 
| 合計ジャッジ時間 | 7,150 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 1 TLE * 1 -- * 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, 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;
        
        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;
                    break;
                }
                if (used[hx][hy][vx>0][vy>0]) {
                    break;
                }
                used[hx][hy][vx>0][vy>0] = true;
            }
        }
        writeln(hit ? "Hit" : "Miss");
    }
}
            
            
            
        