結果
問題 | No.1265 Balloon Survival |
ユーザー |
|
提出日時 | 2021-04-24 00:21:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 4,093 bytes |
コンパイル時間 | 3,649 ms |
コンパイル使用メモリ | 187,184 KB |
最終ジャッジ日時 | 2025-01-21 00:31:11 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <atcoder/all>#include <bitset>#include <fstream>#include <functional>#include <iostream>#include <iomanip>#include <limits>#include <map>#include <math.h>#include <queue>#include <set>#include <sstream>#include <stack>#include <stdio.h>#include <stdlib.h>#include <unordered_map>#include <unordered_set>#include <vector>using namespace std;using namespace atcoder;typedef long long ll;typedef long double ld;typedef pair<int, int> pii;typedef pair<ll, ll> pll;typedef pair<ll, ld> pid;typedef pair<ll, string> pls;typedef vector<bool> vb;typedef vector<vector<bool>> vvb;typedef vector<int> vi;typedef vector<vector<int>> vvi;typedef vector<vector<vector<int>>> vvvi;typedef vector<vector<vector<vector<int>>>> vvvvi;typedef vector<ll> vl;typedef vector<vector<ll>> vvl;typedef vector<vector<vector<ll>>> vvvl;typedef vector<vector<vector<vector<ll>>>> vvvvl;typedef vector<ld> vd;typedef vector<vector<ld>> vvd;typedef vector<string> vs;#define rep(i,n) for(auto i=0; i<n; ++i)#define repm(i,s,n) for(auto i=s; i<n; ++i)#define repd(i,n) for(auto i=n-1; i>=0; --i)#define repdm(i,e,n) for(auto i=n-1; i>=e; --i)#define all(a) (a).begin(), (a).end()#define rall(a) (a).rbegin(), (a).rend()template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }template <class mint, internal::is_modint_t<mint>* = nullptr>constexpr istream& operator>>(istream& is, mint& x) noexcept {long long v = 0; std::cin >> v; x = v; return is;}template <class mint, internal::is_modint_t<mint>* = nullptr>constexpr ostream& operator<<(ostream& os, const mint& x) noexcept {os << x.val(); return os;}inline void _n() { std::cout << std::endl; }template <class T> inline void _(const T a) { std::cout << a; }template <class T> inline void _l(const T a) { _(a); _n(); }template <class T> inline void _s(const T a) { _(a); _(' '); }template <class T> inline void _v(const std::vector<T> v) { for(auto a : v) _(a); }template <class T> inline void _vl(const std::vector<T> v) { for(auto a : v) _l(a); }template <class T> inline void _vs(const std::vector<T> v) { for(auto a : v) _s(a); _n(); }template <class T> inline void _vvl(const std::vector<std::vector<T>> v) { for(auto a : v) { _v(a); _n(); } }template <class T> inline void _vvs(const std::vector<std::vector<T>> v) { for(auto a : v) { _vs(a); } }inline void ynl(const bool b) {_l(b ? "Yes" : "No");}inline void ynu(const bool b) {_l(b ? "YES" : "NO");}const int INF = 1 << 30;const long long INF_LL = 1LL << 62;const long long MOD1 = 1000000007;const long long MOD9 = 998244353;using mint1 = modint1000000007;using mint9 = modint998244353;//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//void input() {}void solve() {using t = tuple<int, int, ld>;int N; cin >> N;vd X(N), Y(N);rep(i, N) cin >> X[i] >> Y[i];vector<t> D;rep(i, N) repm(j, i+1, N) {ld d = sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]));D.push_back({i, j, d});}auto compare = [&] (t a, t b) -> bool {int ai, aj, bi, bj;ld ad, bd;tie(ai, aj, ad) = a;tie(bi, bj, bd) = b;if(ad != bd) return ad < bd;else if(ai != bi) return ai < bi;else return aj < bj;};sort(all(D), compare);int ans = 0;vi B(N);rep(i, D.size()) {int di, dj;ld dd;tie(di, dj, dd) = D[i];if(di == 0 && B[dj] == 0) {ans++;B[dj] = 1;} else if(di != 0 && B[di] == 0 && B[dj] == 0){B[di] = 1;B[dj] = 1;}}_l(ans);}//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//int main() {std::ifstream in("input.txt");std::cin.rdbuf(in.rdbuf());std::cin.tie(0);ios::sync_with_stdio(false);input();solve();return 0;}