結果

問題 No.202 1円玉投げ
ユーザー te-shte-sh
提出日時 2016-09-16 11:24:29
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 374 ms / 5,000 ms
コード長 1,187 bytes
コンパイル時間 713 ms
コンパイル使用メモリ 112,432 KB
実行使用メモリ 88,500 KB
最終ジャッジ日時 2023-09-02 22:13:19
合計ジャッジ時間 9,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 374 ms
88,500 KB
testcase_01 AC 363 ms
83,712 KB
testcase_02 AC 45 ms
67,864 KB
testcase_03 AC 46 ms
67,400 KB
testcase_04 AC 45 ms
67,844 KB
testcase_05 AC 86 ms
69,572 KB
testcase_06 AC 306 ms
81,264 KB
testcase_07 AC 335 ms
83,360 KB
testcase_08 AC 336 ms
82,292 KB
testcase_09 AC 221 ms
76,072 KB
testcase_10 AC 131 ms
71,360 KB
testcase_11 AC 193 ms
74,948 KB
testcase_12 AC 194 ms
75,204 KB
testcase_13 AC 140 ms
71,284 KB
testcase_14 AC 86 ms
68,768 KB
testcase_15 AC 212 ms
76,416 KB
testcase_16 AC 310 ms
81,836 KB
testcase_17 AC 293 ms
80,748 KB
testcase_18 AC 299 ms
79,976 KB
testcase_19 AC 207 ms
76,440 KB
testcase_20 AC 282 ms
80,192 KB
testcase_21 AC 207 ms
76,360 KB
testcase_22 AC 66 ms
67,360 KB
testcase_23 AC 65 ms
67,552 KB
testcase_24 AC 68 ms
67,792 KB
testcase_25 AC 68 ms
67,944 KB
testcase_26 AC 65 ms
68,792 KB
testcase_27 AC 66 ms
67,636 KB
testcase_28 AC 66 ms
67,384 KB
testcase_29 AC 66 ms
69,196 KB
testcase_30 AC 68 ms
67,588 KB
testcase_31 AC 67 ms
67,928 KB
testcase_32 AC 71 ms
68,156 KB
testcase_33 AC 71 ms
68,540 KB
testcase_34 AC 66 ms
68,132 KB
testcase_35 AC 337 ms
88,296 KB
testcase_36 AC 358 ms
87,364 KB
testcase_37 AC 357 ms
82,904 KB
testcase_38 AC 345 ms
87,644 KB
testcase_39 AC 46 ms
67,304 KB
testcase_40 AC 45 ms
67,076 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(17): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`

ソースコード

diff #

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.regex, std.conv, std.stdio, std.typecons;

auto maxX = 2000, maxY = 2000;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto pi = iota(n)
    .map!(_ => readln.split.map!(to!int))
    .map!(rd => point(rd[0], rd[1])).array;

  auto buf = new int[][][](maxY + 1, maxX + 1);

  auto r = 0;
 loop: foreach (int i, p; pi) {
    auto x = p.x / 10, y = p.y / 10;
    auto xi = max(x - 1, 0), xa = min(x + 1, maxX);
    auto yi = max(y - 1, 0), ya = min(y + 1, maxY);

    int[] pc;
    foreach (yc; yi..ya+1)
      foreach (xc; xi..xa+1)
        pc ~= buf[yc][xc];

    foreach (c; pc)
      if ((p - pi[c]).hypot2 < 400) continue loop;

    foreach (yc; yi..ya+1)
      foreach (xc; xi..xa+1)
        buf[yc][xc] ~= i;

    ++r;
  }

  writeln(r);
}

struct Point(T) {
  T 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);
  }

  int hypot2() { return x ^^ 2 + y ^^ 2; }
}

alias Point!int point;
0