結果
| 問題 | No.1265 Balloon Survival |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-23 22:58:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 114 ms / 2,000 ms |
| コード長 | 1,066 bytes |
| コンパイル時間 | 860 ms |
| コンパイル使用メモリ | 82,688 KB |
| 実行使用メモリ | 11,640 KB |
| 最終ジャッジ日時 | 2024-07-21 12:07:13 |
| 合計ジャッジ時間 | 3,596 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;
typedef tuple<long long, int, int> P;
#define g(a, t) get<t>(a)
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
vector<long long> x(N), y(N);
for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
priority_queue<P, vector<P>, greater<P>> q;
for(int i = 0; i < N; i++){
for(int j = i + 1; j < N; j++){
long long temp = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
q.push(P(temp, i, j));
}
}
vector<int> used(N);
int cnt = 0;
while(!q.empty()){
P t = q.top();
q.pop();
int s1 = g(t, 1), s2 = g(t, 2);
if(used[s1] == 1 || used[s2] == 1) continue;
else if(s1 == 0){
used[s2] = 1;
cnt++;
}
else if(s2 == 0){
used[s1] = 1;
cnt++;
}
else{
used[s1] = 1;
used[s2] = 1;
}
}
cout << cnt << endl;
}