提出 #41955901


ソースコード 拡げる

import std;

void read(T...)(string S, ref T args) {
    auto buf = S.split;
    foreach (i, ref arg; args) {
        arg = buf[i].to!(typeof(arg));
    }
}

void read_array(T)(string S, ref T[] arg) {
    arg = S.split.to!(T[]);
}

struct pair {
    int X;
    int Y;
    bool ok;
}

void main () {
    int N, D; read(readln, N, D);
    pair[] cod = new pair[](N);
    foreach (i; 0..N) {
        read(readln, cod[i].X, cod[i].Y);
        cod[i].ok = false;
    }
    // 初期条件
    cod[0].ok = true;

    DList!pair Que;
    Que.insertBack(cod[0]);
    while (!Que.empty) {
        pair target = Que.front; Que.removeFront;
        foreach (ref x; cod) {
            if (x.ok) {
                continue;
            }
            if (is_infected(target, x, D)) {
                x.ok = true;
                Que.insertBack(x);
            }
        }
    }

    // output
    foreach (x; cod) {
        if (x.ok) {
            writeln("Yes");
        } else {
            writeln("No");
        }
    }
}

bool is_infected (pair a, pair b, int D) {
    real dist = sqrt(cast(real)((a.X - b.X)^^2 + (a.Y - b.Y)^^2));
    if (dist <= D) {
        return true;
    }
    return false;
}

提出情報

提出日時
問題 C - Virus
ユーザ InTheBloom
言語 D (DMD 2.091.0)
得点 300
コード長 1253 Byte
結果 AC
実行時間 62 ms
メモリ 4112 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 38
セット名 テストケース
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt
ケース名 結果 実行時間 メモリ
sample00.txt AC 6 ms 3492 KiB
sample01.txt AC 2 ms 3648 KiB
sample02.txt AC 2 ms 3400 KiB
testcase00.txt AC 3 ms 3536 KiB
testcase01.txt AC 62 ms 3948 KiB
testcase02.txt AC 59 ms 4028 KiB
testcase03.txt AC 52 ms 3852 KiB
testcase04.txt AC 59 ms 3912 KiB
testcase05.txt AC 54 ms 4016 KiB
testcase06.txt AC 60 ms 3980 KiB
testcase07.txt AC 51 ms 4028 KiB
testcase08.txt AC 52 ms 3972 KiB
testcase09.txt AC 49 ms 3904 KiB
testcase10.txt AC 51 ms 3928 KiB
testcase11.txt AC 50 ms 3944 KiB
testcase12.txt AC 58 ms 4112 KiB
testcase13.txt AC 51 ms 3804 KiB
testcase14.txt AC 58 ms 3860 KiB
testcase15.txt AC 50 ms 3868 KiB
testcase16.txt AC 8 ms 3936 KiB
testcase17.txt AC 53 ms 3896 KiB
testcase18.txt AC 10 ms 3912 KiB
testcase19.txt AC 49 ms 3924 KiB
testcase20.txt AC 8 ms 3892 KiB
testcase21.txt AC 50 ms 3980 KiB
testcase22.txt AC 12 ms 3968 KiB
testcase23.txt AC 58 ms 4000 KiB
testcase24.txt AC 17 ms 3856 KiB
testcase25.txt AC 6 ms 3912 KiB
testcase26.txt AC 5 ms 3956 KiB
testcase27.txt AC 6 ms 3912 KiB
testcase28.txt AC 20 ms 3904 KiB
testcase29.txt AC 10 ms 3856 KiB
testcase30.txt AC 7 ms 3784 KiB
testcase31.txt AC 52 ms 3944 KiB
testcase32.txt AC 48 ms 3980 KiB
testcase33.txt AC 17 ms 3944 KiB
testcase34.txt AC 15 ms 3956 KiB