結果
問題 |
No.1265 Balloon Survival
|
ユーザー |
![]() |
提出日時 | 2020-11-18 08:30:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 235 ms / 2,000 ms |
コード長 | 964 bytes |
コンパイル時間 | 2,266 ms |
コンパイル使用メモリ | 204,544 KB |
最終ジャッジ日時 | 2025-01-16 01:29:36 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int64_t> X(N), Y(N); for (int i = 0; i < N; i++) { cin >> X[i] >> Y[i]; } priority_queue<pair<int64_t, pair<int, int>>, vector<pair<int64_t, pair<int, int>>>, greater<pair<int64_t, pair<int, int>>>> que; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { que.push(make_pair((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]), make_pair(i, j))); } } int res = 0; set<int> st; while (!que.empty()) { auto q = que.top(); que.pop(); int a = q.second.first, b = q.second.second; if (a == 0 && st.find(b) == st.end()) { res++; st.insert(b); } if (st.find(a) == st.end() && st.find(b) == st.end()) { st.insert(a); st.insert(b); } } cout << res << '\n'; return 0; }