結果
| 問題 |
No.1265 Balloon Survival
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-01-06 12:59:07 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 104 ms / 2,000 ms |
| コード長 | 1,329 bytes |
| コンパイル時間 | 1,505 ms |
| コンパイル使用メモリ | 143,192 KB |
| 実行使用メモリ | 11,744 KB |
| 最終ジャッジ日時 | 2024-11-06 22:36:10 |
| 合計ジャッジ時間 | 3,787 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#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;
ll dist;
Node(int u = -1, int v = -1, ll 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;
}
siman