結果
問題 | No.202 1円玉投げ |
ユーザー | te-sh |
提出日時 | 2017-05-11 12:19:26 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 215 ms / 5,000 ms |
コード長 | 2,672 bytes |
コンパイル時間 | 1,034 ms |
コンパイル使用メモリ | 195,716 KB |
実行使用メモリ | 24,212 KB |
最終ジャッジ日時 | 2024-06-12 19:08:48 |
合計ジャッジ時間 | 7,068 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 196 ms
12,084 KB |
testcase_01 | AC | 212 ms
24,084 KB |
testcase_02 | AC | 5 ms
6,944 KB |
testcase_03 | AC | 4 ms
6,944 KB |
testcase_04 | AC | 5 ms
6,944 KB |
testcase_05 | AC | 31 ms
15,360 KB |
testcase_06 | AC | 181 ms
24,208 KB |
testcase_07 | AC | 194 ms
24,084 KB |
testcase_08 | AC | 200 ms
24,212 KB |
testcase_09 | AC | 120 ms
23,580 KB |
testcase_10 | AC | 63 ms
18,816 KB |
testcase_11 | AC | 115 ms
23,576 KB |
testcase_12 | AC | 108 ms
23,588 KB |
testcase_13 | AC | 71 ms
18,944 KB |
testcase_14 | AC | 28 ms
16,256 KB |
testcase_15 | AC | 116 ms
23,500 KB |
testcase_16 | AC | 181 ms
10,608 KB |
testcase_17 | AC | 197 ms
12,712 KB |
testcase_18 | AC | 179 ms
12,584 KB |
testcase_19 | AC | 115 ms
23,488 KB |
testcase_20 | AC | 169 ms
23,572 KB |
testcase_21 | AC | 113 ms
23,664 KB |
testcase_22 | AC | 6 ms
6,944 KB |
testcase_23 | AC | 6 ms
6,940 KB |
testcase_24 | AC | 5 ms
6,940 KB |
testcase_25 | AC | 6 ms
6,944 KB |
testcase_26 | AC | 10 ms
6,940 KB |
testcase_27 | AC | 9 ms
6,940 KB |
testcase_28 | AC | 5 ms
6,940 KB |
testcase_29 | AC | 6 ms
6,940 KB |
testcase_30 | AC | 9 ms
6,944 KB |
testcase_31 | AC | 6 ms
6,940 KB |
testcase_32 | AC | 9 ms
6,944 KB |
testcase_33 | AC | 6 ms
6,940 KB |
testcase_34 | AC | 7 ms
6,940 KB |
testcase_35 | AC | 189 ms
13,688 KB |
testcase_36 | AC | 187 ms
9,724 KB |
testcase_37 | AC | 215 ms
24,212 KB |
testcase_38 | AC | 188 ms
13,788 KB |
testcase_39 | AC | 5 ms
6,940 KB |
testcase_40 | AC | 4 ms
6,940 KB |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; alias Point!int point; const maxX = 20000, maxY = 20000, gs = 20; auto grid = Grid!(point[], int)(maxX / gs + 1, maxY / gs + 1); void main() { auto n = readln.chomp.to!size_t; auto r = 0; foreach (_; 0..n) { auto rd = readln.split.to!(int[]), p = point(rd[0], rd[1]), gp = p / gs; if (!isOverlap(p, gp)) { grid[gp] ~= p; ++r; } } writeln(r); } auto isOverlap(point p, point gp) { foreach (q; grid.sibPoints8(gp).chain([gp])) foreach (tp; grid[q]) if ((p - tp).hypot2 < 400) return true; return false; } struct Point(T) { T x, y; pure auto opBinary(string op: "+")(Point!T rhs) const { return Point!T(x + rhs.x, y + rhs.y); } pure auto opBinary(string op: "-")(Point!T rhs) const { return Point!T(x - rhs.x, y - rhs.y); } pure auto opBinary(string op: "*")(Point!T rhs) const { return x * rhs.x + y * rhs.y; } pure auto opBinary(string op: "*")(T a) const { return Point!T(x * a, y * a); } pure auto opBinary(string op: "/")(T a) const { return Point!T(x / a, y / a); } pure auto hypot2() const { return x ^^ 2 + y ^^ 2; } } struct Grid(T, U) { import std.algorithm, std.conv, std.range, std.traits, std.typecons; const sibs4 = [Point!U(-1, 0), Point!U(0, -1), Point!U(1, 0), Point!U(0, 1)]; const sibs8 = [Point!U(-1, 0), Point!U(-1, -1), Point!U(0, -1), Point!U(1, -1), Point!U(1, 0), Point!U(1, 1), Point!U(0, 1), Point!U(-1, 1)]; T[][] m; const size_t rows, cols; mixin Proxy!m; this(size_t r, size_t c) { rows = r; cols = c; m = new T[][](rows, cols); } this(T[][] s) { rows = s.length; cols = s[0].length; m = s; } pure auto opIndex(Point!U p) const { return m[p.y][p.x]; } pure auto opIndex(size_t y) { return m[y]; } pure auto opIndex(size_t y, size_t x) const { return m[y][x]; } static if (isAssignable!T) { auto opIndexAssign(T v, Point!U p) { return m[p.y][p.x] = v; } auto opIndexAssign(T v, size_t y, size_t x) { return m[y][x] = v; } auto opIndexOpAssign(string op, V)(V v, Point!U p) { return mixin("m[p.y][p.x] " ~ op ~ "= v"); } auto opIndexOpAssign(string op, V)(V v, size_t y, size_t x) { return mixin("m[y][x] " ~ op ~ "= v"); } } pure auto validPoint(Point!U p) const { return p.x >= 0 && p.x < cols && p.y >= 0 && p.y < rows; } pure auto points() const { return rows.to!U.iota.map!(y => cols.to!U.iota.map!(x => Point!U(x, y))).joiner; } pure auto sibPoints4(Point!U p) const { return sibs4.map!(s => p + s).filter!(p => validPoint(p)); } pure auto sibPoints8(Point!U p) const { return sibs8.map!(s => p + s).filter!(p => validPoint(p)); } }