結果
問題 | No.1265 Balloon Survival |
ユーザー |
|
提出日時 | 2020-10-23 22:19:27 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 228 ms / 2,000 ms |
コード長 | 973 bytes |
コンパイル時間 | 941 ms |
コンパイル使用メモリ | 149,304 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2024-06-22 09:45:22 |
合計ジャッジ時間 | 4,791 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;import std.typecons, std.range, std.random, std.math, std.container;import std.numeric, std.bigint, core.bitop, core.stdc.stdlib, std.datetime;void main() {auto N = readln.chomp.to!int;auto A = iota(N).map!(_ => readln.split.map!(to!long).array).array;long dist(int i, int j) {return (A[i][0] - A[j][0]) ^^ 2 + (A[i][1] - A[j][1]) ^^ 2;}auto pq = new BinaryHeap!(Array!(Tuple!(int, int, long)), "a[2] > b[2]");foreach (i; 0..N) foreach (j; i+1..N) pq.insert(tuple(i, j, dist(i, j)));auto used = new bool[](N);int ans = 0;while (!pq.empty) {auto i = pq.front[0];auto j = pq.front[1];pq.removeFront;if (used[i] || used[j]) {continue;} if (i == 0) {ans += 1;used[j] = true;} else {used[i] = used[j] = true;}}ans.writeln;}