結果

問題 No.61 リベリオン
ユーザー nebukuro09nebukuro09
提出日時 2017-03-09 14:55:27
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 1,649 bytes
コンパイル時間 792 ms
コンパイル使用メモリ 91,960 KB
実行使用メモリ 7,108 KB
最終ジャッジ日時 2023-09-03 01:47:18
合計ジャッジ時間 7,423 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/dmd2/linux/bin64/../../src/phobos/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`

ソースコード

diff #

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");
    }
}
0