結果

問題 No.202 1円玉投げ
ユーザー te-shte-sh
提出日時 2016-09-16 11:13:17
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 1,208 bytes
コンパイル時間 1,092 ms
コンパイル使用メモリ 119,116 KB
実行使用メモリ 33,960 KB
最終ジャッジ日時 2023-09-02 22:12:54
合計ジャッジ時間 14,689 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(18): 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 = 20000, maxY = 20000;

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 xb = new int[][](maxX + 1);
  auto yb = new int[][](maxY + 1);

  auto r = 0;
 loop: foreach (int i, p; pi) {
    auto xi = max(p.x - 10, 0), xa = min(p.x + 10, maxX);
    auto yi = max(p.y - 10, 0), ya = min(p.y + 10, maxY);
    int[] xc, yc;
    foreach (x; xi..xa+1) xc ~= xb[x];
    foreach (y; yi..ya+1) yc ~= yb[y];
    foreach (c; setIntersection(xc.sort().uniq(), yc.sort().uniq()))
      if ((p - pi[c]).hypot2 < 400) continue loop;
    xb[xi] ~= i; xb[xa] ~= i;
    yb[yi] ~= i; yb[ya] ~= 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