結果
問題 | No.1265 Balloon Survival |
ユーザー |
![]() |
提出日時 | 2021-01-06 12:56:32 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,337 bytes |
コンパイル時間 | 1,490 ms |
コンパイル使用メモリ | 142,964 KB |
実行使用メモリ | 11,616 KB |
最終ジャッジ日時 | 2024-11-06 22:33:30 |
合計ジャッジ時間 | 3,816 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 WA * 1 |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <limits.h> #include <map> #include <queue> #include <set> #include <string.h> #include <vector> using namespace std; typedef long long ll; struct Node { int u; int v; double dist; Node(int u = -1, int v = -1, double dist = 0.0) { this->u = u; this->v = v; this->dist = dist; } bool operator>(const Node &n) const { return dist > n.dist; } }; int main() { int N; cin >> N; vector<ll> X(N); vector<ll> Y(N); for (int i = 0; i < N; ++i) { cin >> X[i] >> Y[i]; } priority_queue <Node, vector<Node>, greater<Node>> pque; for (int i = 0; i < N; ++i) { ll x1 = X[i]; ll y1 = Y[i]; for (int j = i + 1; j < N; ++j) { ll x2 = X[j]; ll y2 = Y[j]; ll dx = x1 - x2; ll dy = y1 - y2; pque.push(Node(i, j, dx * dx + dy * dy)); } } int ans = 0; bool checked[N]; memset(checked, false, sizeof(checked)); while (!pque.empty()) { Node node = pque.top(); pque.pop(); if (checked[node.u]) continue; if (checked[node.v]) continue; if (node.u == 0) { ++ans; checked[node.v] = true; } else { checked[node.u] = true; checked[node.v] = true; } } cout << ans << endl; return 0; }