結果

問題 No.202 1円玉投げ
ユーザー te-sh
提出日時 2016-09-16 11:24:29
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 366 ms / 5,000 ms
コード長 1,187 bytes
コンパイル時間 1,019 ms
コンパイル使用メモリ 121,216 KB
実行使用メモリ 86,456 KB
最終ジャッジ日時 2024-06-12 04:26:50
合計ジャッジ時間 9,536 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます
コンパイルメッセージ
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